Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix!: r144 geometry rename #225

Merged
merged 3 commits into from
Dec 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/troika-3d/objects.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ An example using `initThreeObject()`:

```js
import { Object3DFacade } from 'troika-3d'
import { Mesh, BoxBufferGeometry, MeshStandardMaterial } from 'three'
import { Mesh, BoxGeometry, MeshStandardMaterial } from 'three'

// It's often to define a singleton geometry instance that can be used
// across all instances of this object type:
const geometry = new BoxBufferGeometry()
const geometry = new BoxGeometry()

class MyObject extends Object3DFacade {
initThreeObject() {
Expand Down
2 changes: 1 addition & 1 deletion packages/three-instanced-uniforms-mesh/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@
"troika-three-utils": "^0.46.0"
},
"peerDependencies": {
"three": ">=0.103.0"
"three": ">=0.125.0"
}
}
2 changes: 1 addition & 1 deletion packages/troika-3d-text/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@
"troika-three-utils": "^0.46.0"
},
"peerDependencies": {
"three": ">=0.103.0"
"three": ">=0.125.0"
}
}
6 changes: 3 additions & 3 deletions packages/troika-3d-text/src/facade/SelectionRangeRect.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { BoxBufferGeometry, Color, Mesh, MeshBasicMaterial, Vector2, Vector4 } from 'three'
import { BoxGeometry, Color, Mesh, MeshBasicMaterial, Vector2, Vector4 } from 'three'
import {Instanceable3DFacade, createDerivedMaterial} from 'troika-3d'

const tempVec4 = new Vector4()
Expand Down Expand Up @@ -35,11 +35,11 @@ if (rad != 0.0) {
)
const meshes = {
normal: new Mesh(
new BoxBufferGeometry(1, 1, 1).translate(0.5, 0.5, 0.5),
new BoxGeometry(1, 1, 1).translate(0.5, 0.5, 0.5),
material
),
curved: new Mesh(
new BoxBufferGeometry(1, 1, 1, 32).translate(0.5, 0.5, 0.5),
new BoxGeometry(1, 1, 1, 32).translate(0.5, 0.5, 0.5),
material
)
}
Expand Down
2 changes: 1 addition & 1 deletion packages/troika-3d-ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@
"troika-three-utils": "^0.46.0"
},
"peerDependencies": {
"three": ">=0.103.0"
"three": ">=0.125.0"
}
}
4 changes: 2 additions & 2 deletions packages/troika-3d-ui/src/facade/ScrollbarsFacade.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Object3DFacade, ParentFacade } from 'troika-3d'
import { CylinderBufferGeometry, Mesh, MeshBasicMaterial } from 'three'
import { CylinderGeometry, Mesh, MeshBasicMaterial } from 'three'

let barGeometry

Expand All @@ -8,7 +8,7 @@ class ScrollbarBarFacade extends Object3DFacade {
constructor(parent) {
const mesh = new Mesh(
barGeometry || (barGeometry =
new CylinderBufferGeometry(0.5, 0.5, 1, 8).translate(0, -0.5, 0)
new CylinderGeometry(0.5, 0.5, 1, 8).translate(0, -0.5, 0)
),
// TODO allow overriding material
new MeshBasicMaterial({
Expand Down
4 changes: 2 additions & 2 deletions packages/troika-3d-ui/src/facade/UIBlock3DFacade.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Mesh, Vector2, Vector3, Vector4, PlaneBufferGeometry, Sphere, Matrix4, Plane } from 'three'
import { Mesh, Vector2, Vector3, Vector4, PlaneGeometry, Sphere, Matrix4, Plane } from 'three'
import { Group3DFacade } from 'troika-3d'
import UITextNode3DFacade from './UITextNode3DFacade.js'
import UIBlockLayer3DFacade from './UIBlockLayer3DFacade.js'
Expand All @@ -7,7 +7,7 @@ import { getComputedFontSize, getInheritable, INHERITABLES } from '../uiUtils.js
import ScrollbarsFacade from './ScrollbarsFacade.js'
import { invertMatrix4 } from 'troika-three-utils'

const raycastMesh = new Mesh(new PlaneBufferGeometry(1, 1).translate(0.5, -0.5, 0))
const raycastMesh = new Mesh(new PlaneGeometry(1, 1).translate(0.5, -0.5, 0))
const tempMat4 = new Matrix4()
const tempVec4 = new Vector4(0,0,0,0)
const emptyVec4 = Object.freeze(new Vector4(0,0,0,0))
Expand Down
4 changes: 2 additions & 2 deletions packages/troika-3d-ui/src/facade/UIBlockLayer3DFacade.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Instanceable3DFacade } from 'troika-3d'
import { Color, Mesh, MeshBasicMaterial, PlaneBufferGeometry, Vector2, Vector4 } from 'three'
import { Color, Mesh, MeshBasicMaterial, PlaneGeometry, Vector2, Vector4 } from 'three'
import { createUIBlockLayerDerivedMaterial } from './UIBlockLayerDerivedMaterial.js'

const geometry = new PlaneBufferGeometry(1, 1).translate(0.5, -0.5, 0)
const geometry = new PlaneGeometry(1, 1).translate(0.5, -0.5, 0)
const defaultMaterial = new MeshBasicMaterial({color: 0})
const emptyVec2 = Object.freeze(new Vector2())
const emptyVec4 = Object.freeze(new Vector4(0,0,0,0))
Expand Down
4 changes: 2 additions & 2 deletions packages/troika-3d-ui/src/facade/UIImage3DFacade.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { extendAsFlexNode } from '../flex-layout/FlexNode.js'
import { Mesh, MeshBasicMaterial, PlaneBufferGeometry, TextureLoader } from 'three'
import { Mesh, MeshBasicMaterial, PlaneGeometry, TextureLoader } from 'three'
import { Object3DFacade } from 'troika-3d'


const geometry = new PlaneBufferGeometry(1, 1).translate(0.5, -0.5, 0)
const geometry = new PlaneGeometry(1, 1).translate(0.5, -0.5, 0)
const defaultMaterial = new MeshBasicMaterial()
const loader = new TextureLoader()

Expand Down
14 changes: 7 additions & 7 deletions packages/troika-3d-ui/src/facade/widgets/ColorPickerFacade.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ import { Group3DFacade, Object3DFacade } from 'troika-3d'
import {
BackSide,
Color,
CylinderBufferGeometry,
CylinderGeometry,
Mesh,
MeshBasicMaterial,
Plane,
PlaneBufferGeometry,
SphereBufferGeometry,
PlaneGeometry,
SphereGeometry,
Vector3
} from 'three'
import { createDerivedMaterial } from 'troika-three-utils'
Expand Down Expand Up @@ -72,7 +72,7 @@ function rgb2hsv (r, g, b) {
return [h, s, v]
}

const cylinderGeometry = new CylinderBufferGeometry(0.5, 0.5, 1, 45)
const cylinderGeometry = new CylinderGeometry(0.5, 0.5, 1, 45)
.translate(0, 0.5, 0)
.rotateX(Math.PI / 2)
.rotateZ(Math.PI / 2) //orient uv
Expand Down Expand Up @@ -145,9 +145,9 @@ class HsvCylinderBg extends Object3DFacade {

class ValueStick extends Object3DFacade {
constructor (parent) {
const ballGeom = new SphereBufferGeometry(0.05, 16, 12)
const ballGeom = new SphereGeometry(0.05, 16, 12)
.translate(0, 0, 0.5)
const stickGeom = new CylinderBufferGeometry(0.005, 0.005, 0.5, 6)
const stickGeom = new CylinderGeometry(0.005, 0.005, 0.5, 6)
.translate(0, 0.25, 0).rotateX(Math.PI / 2)

const material = new MeshBasicMaterial()
Expand Down Expand Up @@ -180,7 +180,7 @@ class ValuePlane extends Object3DFacade {
`
})
super(parent, new Mesh(
new PlaneBufferGeometry(),
new PlaneGeometry(),
material
))
}
Expand Down
2 changes: 1 addition & 1 deletion packages/troika-3d/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@
"troika-three-utils": "^0.46.0"
},
"peerDependencies": {
"three": ">=0.103.0"
"three": ">=0.125.0"
}
}
8 changes: 4 additions & 4 deletions packages/troika-3d/src/facade/primitives/BoxFacade.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { utils } from 'troika-core'
import { BoxBufferGeometry } from 'three'
import { BoxGeometry } from 'three'
import { MeshFacade } from './MeshFacade.js'

/**
* Return a singleton instance of a 1x1x1 BoxBufferGeometry
* @type {function(): BoxBufferGeometry}
* Return a singleton instance of a 1x1x1 BoxGeometry
* @type {function(): BoxGeometry}
*/
export const getBoxGeometry = utils.memoize(() => {
return new BoxBufferGeometry(1, 1, 1, 1, 1)
return new BoxGeometry(1, 1, 1, 1, 1)
})


Expand Down
4 changes: 2 additions & 2 deletions packages/troika-3d/src/facade/primitives/CircleFacade.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { utils } from 'troika-core'
import { CircleBufferGeometry, DoubleSide } from 'three'
import { CircleGeometry, DoubleSide } from 'three'
import { MeshFacade } from './MeshFacade.js'

const geometries = Object.create(null, [
Expand All @@ -9,7 +9,7 @@ const geometries = Object.create(null, [
].reduce((descr, [name, segments]) => {
descr[name] = {
get: utils.memoize(() =>
new CircleBufferGeometry(1, segments).rotateX(-Math.PI / 2)
new CircleGeometry(1, segments).rotateX(-Math.PI / 2)
)
}
return descr
Expand Down
4 changes: 2 additions & 2 deletions packages/troika-3d/src/facade/primitives/PlaneFacade.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { utils } from 'troika-core'
import { DoubleSide, PlaneBufferGeometry } from 'three'
import { DoubleSide, PlaneGeometry } from 'three'
import { MeshFacade } from './MeshFacade.js'

const getGeometry = utils.memoize(() => {
return new PlaneBufferGeometry(1, 1, 1, 1).rotateX(-Math.PI / 2)
return new PlaneGeometry(1, 1, 1, 1).rotateX(-Math.PI / 2)
})

/**
Expand Down
4 changes: 2 additions & 2 deletions packages/troika-3d/src/facade/primitives/SphereFacade.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { utils } from 'troika-core'
import { SphereBufferGeometry } from 'three'
import { SphereGeometry } from 'three'
import { MeshFacade } from './MeshFacade.js'

const geometries = Object.create(null, [
Expand All @@ -8,7 +8,7 @@ const geometries = Object.create(null, [
['high', 64, 48]
].reduce((descr, [name, wSegs, hSegs]) => {
descr[name] = {
get: utils.memoize(() => new SphereBufferGeometry(1, wSegs, hSegs))
get: utils.memoize(() => new SphereGeometry(1, wSegs, hSegs))
}
return descr
}, {}))
Expand Down
4 changes: 2 additions & 2 deletions packages/troika-examples/arcs/ArcFacade.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import {Mesh, ShaderMaterial, MeshStandardMaterial, BoxBufferGeometry, Color, Sphere, Vector3, DoubleSide} from 'three'
import {Mesh, ShaderMaterial, MeshStandardMaterial, BoxGeometry, Color, Sphere, Vector3, DoubleSide} from 'three'
import {Object3DFacade, createDerivedMaterial} from 'troika-3d'
import arcVertexShader from './arcVertexShader.glsl'
import arcFragmentShader from './arcFragmentShader.glsl'

const baseColor = new Color(0x3ba7db)
const highlightColor = new Color(0xffffff)

const baseGeometry = new BoxBufferGeometry(1, 1, 1, 8, 1, 1)
const baseGeometry = new BoxGeometry(1, 1, 1, 8, 1, 1)

const customShaderMaterial = new ShaderMaterial({
uniforms: {
Expand Down
4 changes: 2 additions & 2 deletions packages/troika-examples/bezier-3d/ShadowSurfaceFacade.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import {Object3DFacade} from 'troika-3d'
import { Mesh, MeshStandardMaterial, PlaneBufferGeometry } from 'three'
import { Mesh, MeshStandardMaterial, PlaneGeometry } from 'three'

export default class ShadowSurface extends Object3DFacade {
initThreeObject() {
return new Mesh(
new PlaneBufferGeometry(),
new PlaneGeometry(),
new MeshStandardMaterial({
color: 0x333333,
roughness: 0.8,
Expand Down
4 changes: 2 additions & 2 deletions packages/troika-examples/citygrid/Host.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {BoxBufferGeometry, MeshLambertMaterial, Color, Mesh, BufferGeometry, BufferAttribute} from 'three'
import {BoxGeometry, MeshLambertMaterial, Color, Mesh, BufferGeometry, BufferAttribute} from 'three'
import {Object3DFacade} from 'troika-3d'

/*
Expand All @@ -20,7 +20,7 @@ hostGeometry.setAttribute('position', new BufferAttribute(new Float32Array([
0,0,1, 1,0,1, 1,1,1
].map((n, i) => (i + 1) % 3 ? n - 0.5 : n)), 3))
*/
const hostGeometry = new BoxBufferGeometry(1, 1, 1)
const hostGeometry = new BoxGeometry(1, 1, 1)
hostGeometry.translate(0, 0, .5)

const hostMaterials = {
Expand Down
4 changes: 2 additions & 2 deletions packages/troika-examples/citygrid/Zone.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import React from 'react'
import {Group, Mesh, Line, BufferGeometry, BufferAttribute, CylinderBufferGeometry, MeshLambertMaterial, LineBasicMaterial, DoubleSide} from 'three'
import {Group, Mesh, Line, BufferGeometry, BufferAttribute, CylinderGeometry, MeshLambertMaterial, LineBasicMaterial, DoubleSide} from 'three'
import {Object3DFacade, HtmlOverlay3DFacade} from 'troika-3d'
import Tooltip from './Tooltip.jsx'


const wallsGeometry = new CylinderBufferGeometry(Math.sqrt(2) / 2, Math.sqrt(2) / 2, 1, 4, 1, true)
const wallsGeometry = new CylinderGeometry(Math.sqrt(2) / 2, Math.sqrt(2) / 2, 1, 4, 1, true)
.rotateY(Math.PI / 4)
.rotateX(Math.PI / 2)
.translate(0.5, 0.5, 0.5)
Expand Down
4 changes: 2 additions & 2 deletions packages/troika-examples/dragdrop/Planet.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {
SphereBufferGeometry,
SphereGeometry,
Mesh,
MeshPhongMaterial
} from 'three'
Expand All @@ -8,7 +8,7 @@ import {
} from 'troika-3d'


const geometry = new SphereBufferGeometry(1, 32, 32)
const geometry = new SphereGeometry(1, 32, 32)
const material = new MeshPhongMaterial({
transparent: true
})
Expand Down
4 changes: 2 additions & 2 deletions packages/troika-examples/dragdrop/Sun.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {
SphereBufferGeometry,
SphereGeometry,
Mesh,
MeshBasicMaterial
} from 'three'
Expand All @@ -8,7 +8,7 @@ import {
} from 'troika-3d'


const geometry = new SphereBufferGeometry(.02, 16, 16)
const geometry = new SphereGeometry(.02, 16, 16)
const material = new MeshBasicMaterial({
color: 0xffffff
})
Expand Down
4 changes: 2 additions & 2 deletions packages/troika-examples/flexbox/FlexboxGlobe.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { Object3DFacade } from 'troika-3d'
import { extendAsFlexNode } from 'troika-3d-ui'
import { Mesh, MeshStandardMaterial, SphereBufferGeometry, TextureLoader } from 'three'
import { Mesh, MeshStandardMaterial, SphereGeometry, TextureLoader } from 'three'

/**
* A globe that participates in flexbox layout
*/
class FlexboxGlobe extends Object3DFacade {
initThreeObject() {
return new Mesh(
new SphereBufferGeometry(0.5, 64, 64),
new SphereGeometry(0.5, 64, 64),
new MeshStandardMaterial({
map: new TextureLoader().load('globe/texture_day.jpg'),
roughness: 0.5,
Expand Down
4 changes: 2 additions & 2 deletions packages/troika-examples/globe-connections/Globe.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
Mesh,
MeshBasicMaterial,
MeshStandardMaterial,
SphereBufferGeometry,
SphereGeometry,
Vector3
} from 'three'
import geojson from './countries.geojson.json'
Expand Down Expand Up @@ -71,7 +71,7 @@ const positionAttr = new BufferAttribute(new Float32Array(lineSegmentPositions),
countryBordersGeometry.setAttribute('position', positionAttr)
countryBordersGeometry.setAttribute('normal', positionAttr) //positions are based off r=1 so they can be used directly as normals

const sphereGeometry = new SphereBufferGeometry(1, 32, 24)
const sphereGeometry = new SphereGeometry(1, 32, 24)
const sphereMaterial = createDerivedMaterial(new MeshBasicMaterial({
color: 0x6666ff,
transparent: true,
Expand Down
4 changes: 2 additions & 2 deletions packages/troika-examples/globe/Earth.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {ListFacade} from 'troika-core'
import {Object3DFacade} from 'troika-3d'
import {Mesh, MeshPhongMaterial, SphereBufferGeometry, TextureLoader} from 'three'
import {Mesh, MeshPhongMaterial, SphereGeometry, TextureLoader} from 'three'
import Country from './Country'
import geojson from './countries.geojson.json'

Expand All @@ -21,7 +21,7 @@ Object.keys(geojson).forEach(region => {
class Earth extends Object3DFacade {
constructor(parent) {
let mesh = new Mesh(
new SphereBufferGeometry(.995, 64, 64),
new SphereGeometry(.995, 64, 64),
new MeshPhongMaterial()
)
super(parent, mesh)
Expand Down
4 changes: 2 additions & 2 deletions packages/troika-examples/html-overlays/Box.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {
BoxBufferGeometry,
BoxGeometry,
Mesh,
MeshPhongMaterial,
DoubleSide
Expand All @@ -11,7 +11,7 @@ import {

const BOX_SIZE = 40

const geometry = new BoxBufferGeometry(BOX_SIZE, BOX_SIZE, BOX_SIZE)
const geometry = new BoxGeometry(BOX_SIZE, BOX_SIZE, BOX_SIZE)
const material = new MeshPhongMaterial({
color: 0x003300,
opacity: 0.6,
Expand Down
4 changes: 2 additions & 2 deletions packages/troika-examples/html-overlays/Dot.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {
SphereBufferGeometry,
SphereGeometry,
Mesh,
MeshPhongMaterial
} from 'three'
Expand All @@ -8,7 +8,7 @@ import {
} from 'troika-3d'


const geometry = new SphereBufferGeometry(1)
const geometry = new SphereGeometry(1)
const material = new MeshPhongMaterial({
color: 0x993333
})
Expand Down
Loading