Skip to content

Commit

Permalink
Geometry removed
Browse files Browse the repository at this point in the history
Only BufferGeometry is supported.
Every BufferGeometry helper (e.g. BoxBufferGeometry) has
been renamed to shorter name (e.g. BoxGeometry)
  • Loading branch information
ppillot committed Mar 17, 2024
1 parent d242234 commit 0f1d1d4
Show file tree
Hide file tree
Showing 10 changed files with 22 additions and 26 deletions.
4 changes: 2 additions & 2 deletions src/buffer/box-buffer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* @private
*/

import { BoxBufferGeometry, Vector3, Matrix4 } from 'three'
import { BoxGeometry, Vector3, Matrix4 } from 'three'

import { BufferRegistry } from '../globals'
import GeometryBuffer from './geometry-buffer'
Expand Down Expand Up @@ -41,7 +41,7 @@ class BoxBuffer extends GeometryBuffer {
_size: Float32Array

constructor (data: BoxBufferData, params: Partial<BufferParameters> = {}) {
super(data, params, new BoxBufferGeometry(1, 1, 1))
super(data, params, new BoxGeometry(1, 1, 1))

this.setAttributes(data, true)
}
Expand Down
4 changes: 2 additions & 2 deletions src/buffer/cone-buffer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* @private
*/

import { Matrix4, Vector3, ConeBufferGeometry } from 'three'
import { Matrix4, Vector3, ConeGeometry } from 'three'

import { BufferRegistry } from '../globals'
import { defaults } from '../utils'
Expand All @@ -18,7 +18,7 @@ const target = new Vector3()
const up = new Vector3(0, 1, 0)

function getGeo (params: Partial<ConeBufferParameters> = {}) {
const geo = new ConeBufferGeometry(
const geo = new ConeGeometry(
1, // radius
1, // height
defaults(params.radialSegments, 60), // radialSegments
Expand Down
4 changes: 2 additions & 2 deletions src/buffer/cylindergeometry-buffer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* @private
*/

import { Matrix4, Vector3, CylinderBufferGeometry } from 'three'
import { Matrix4, Vector3, CylinderGeometry } from 'three'

import { defaults } from '../utils'
import { calculateCenterArray, serialBlockArray } from '../math/array-utils'
Expand Down Expand Up @@ -47,7 +47,7 @@ function getGeo (params: Partial<CylinderGeometryBufferParameters> = {}) {
const openEnded = defaults(params.openEnded, true)
const matrix = new Matrix4().makeRotationX(Math.PI / 2)

const geo = new CylinderBufferGeometry(
const geo = new CylinderGeometry(
1, // radiusTop,
1, // radiusBottom,
1, // height,
Expand Down
4 changes: 2 additions & 2 deletions src/buffer/ellipsoid-buffer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* @private
*/

import { IcosahedronBufferGeometry, Vector3, Matrix4 } from 'three'
import { IcosahedronGeometry, Vector3, Matrix4 } from 'three'

import { BufferRegistry } from '../globals'
import { defaults } from '../utils'
Expand Down Expand Up @@ -50,7 +50,7 @@ class EllipsoidBuffer extends GeometryBuffer {
_radius: Float32Array

constructor (data: EllipsoidBufferData, params: Partial<EllipsoidBufferParameters> = {}) {
super(data, params, new IcosahedronBufferGeometry(1, defaults(params.sphereDetail, 2)))
super(data, params, new IcosahedronGeometry(1, defaults(params.sphereDetail, 2)))

this.setAttributes(data, true)
}
Expand Down
4 changes: 2 additions & 2 deletions src/buffer/octahedron-buffer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* @private
*/

import { OctahedronBufferGeometry, Vector3, Matrix4 } from 'three'
import { OctahedronGeometry, Vector3, Matrix4 } from 'three'
import { BufferRegistry } from '../globals'
import GeometryBuffer from './geometry-buffer'
import { BufferData, BufferParameters } from './buffer'
Expand Down Expand Up @@ -40,7 +40,7 @@ class OctahedronBuffer extends GeometryBuffer {
_size: Float32Array

constructor (data: OctahedronBufferData, params: Partial<BufferParameters> = {}) {
super(data, params, new OctahedronBufferGeometry(1, 0))
super(data, params, new OctahedronGeometry(1, 0))

this.setAttributes(data, true)
}
Expand Down
4 changes: 2 additions & 2 deletions src/buffer/spheregeometry-buffer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* @private
*/

import { IcosahedronBufferGeometry, Vector3, Matrix4 } from 'three'
import { IcosahedronGeometry, Vector3, Matrix4 } from 'three'
import { defaults } from '../utils'
import GeometryBuffer from './geometry-buffer'
import { SphereBufferData } from './sphere-buffer'
Expand Down Expand Up @@ -42,7 +42,7 @@ class SphereGeometryBuffer extends GeometryBuffer {
* @param {BufferParameters} params - parameter object
*/
constructor (data: SphereBufferData, params: Partial<SphereGeometryBufferParameters> = {}) {
super(data, params, new IcosahedronBufferGeometry(1, defaults(params.sphereDetail, 1)))
super(data, params, new IcosahedronGeometry(1, defaults(params.sphereDetail, 1)))

this.setAttributes(data, true)
}
Expand Down
4 changes: 2 additions & 2 deletions src/buffer/tetrahedron-buffer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* @private
*/

import { TetrahedronBufferGeometry, Vector3, Matrix4 } from 'three'
import { TetrahedronGeometry, Vector3, Matrix4 } from 'three'
import { BufferRegistry } from '../globals'
import GeometryBuffer from './geometry-buffer'
import { BufferData, BufferParameters } from './buffer'
Expand Down Expand Up @@ -40,7 +40,7 @@ class TetrahedronBuffer extends GeometryBuffer {
_size: Float32Array

constructor (data: TetrahedronBufferData, params: Partial<BufferParameters> = {}) {
super(data, params, new TetrahedronBufferGeometry(1, 0))
super(data, params, new TetrahedronGeometry(1, 0))

this.setAttributes(data, true)
}
Expand Down
4 changes: 2 additions & 2 deletions src/buffer/torus-buffer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* @private
*/

import { TorusBufferGeometry, Vector3, Matrix4 } from 'three'
import { TorusGeometry, Vector3, Matrix4 } from 'three'

import { BufferRegistry } from '../globals'
import { defaults } from '../utils'
Expand Down Expand Up @@ -52,7 +52,7 @@ class TorusBuffer extends GeometryBuffer {
_radius: Float32Array

constructor (data: TorusBufferData, params: Partial<TorusBufferParameters> = {}) {
super(data, params, new TorusBufferGeometry(
super(data, params, new TorusGeometry(
1,
defaults(params.radiusRatio, 0.2),
defaults(params.radialSegments, 16),
Expand Down
12 changes: 4 additions & 8 deletions src/surface/surface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* @private
*/

import { Vector3, Box3, Geometry, BufferGeometry, Group, Color } from 'three'
import { Vector3, Box3, BufferGeometry, Group, Color } from 'three'

import { Debug, Log, ColormakerRegistry } from '../globals'
import { getUintArray } from '../utils'
Expand Down Expand Up @@ -66,8 +66,7 @@ class Surface {
this.center = new Vector3()
this.boundingBox = new Box3()

if (data instanceof Geometry ||
data instanceof BufferGeometry ||
if (data instanceof BufferGeometry ||
data instanceof Group
) {
// to be removed
Expand Down Expand Up @@ -130,15 +129,12 @@ class Surface {
this.contour = contour
}

fromGeometry (geometry: Geometry|BufferGeometry|Group) {
fromGeometry (geometry: BufferGeometry|Group) {
if (Debug) Log.time('GeometrySurface.fromGeometry')

let geo

if (geometry instanceof Geometry) {
geometry.computeVertexNormals(true)
geo = new BufferGeometry().fromGeometry(geometry)
} else if (geometry instanceof BufferGeometry) {
if (geometry instanceof BufferGeometry) {
geo = geometry
} else {
geo = (geometry as any)[ 0 ]
Expand Down
4 changes: 2 additions & 2 deletions src/viewer/viewer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
NearestFilter, LinearFilter, AdditiveBlending,
RGBAFormat, FloatType, /*HalfFloatType, */UnsignedByteType,
ShaderMaterial,
PlaneGeometry, Geometry,
PlaneGeometry,
Scene, Mesh, Group, Object3D, Uniform,
Fog, SpotLight, AmbientLight,
BufferGeometry, BufferAttribute,
Expand Down Expand Up @@ -54,7 +54,7 @@ const pixelOrder = [12,7,13,17,11,6,8,18,16,2,14,22,10,1,3,9,19,23,21,15,5,0,4,2

const tmpMatrix = new Matrix4()

function onBeforeRender (this: Object3D, renderer: WebGLRenderer, scene: Scene, camera: PerspectiveCamera|OrthographicCamera, geometry: Geometry, material: ShaderMaterial/*, group */) {
function onBeforeRender (this: Object3D, renderer: WebGLRenderer, scene: Scene, camera: PerspectiveCamera|OrthographicCamera, geometry: BufferGeometry, material: ShaderMaterial/*, group */) {
const u = material.uniforms
const updateList = []

Expand Down

0 comments on commit 0f1d1d4

Please sign in to comment.