| color?: Color | color?: Color | ||||
| wireframe?: boolean | wireframe?: boolean | ||||
| linewidth?: number | |||||
| isRawShaderMaterial?: boolean | isRawShaderMaterial?: boolean | ||||
| isPhysicalMaterial?: boolean | isPhysicalMaterial?: boolean |
| import {BufferGeometry, NormalBufferAttributes, NormalOrGLBufferAttributes} from 'three' | |||||
| import type {IGeometry, IGeometryEvent, IGeometryEventTypes} from '../IGeometry' | |||||
| import {iGeometryCommons} from './iGeometryCommons' | |||||
| import type {IObject3D} from '../IObject' | |||||
| export class BufferGeometry2<Attributes extends NormalOrGLBufferAttributes = NormalBufferAttributes> extends BufferGeometry<Attributes, IGeometryEvent, IGeometryEventTypes> implements IGeometry<Attributes> { | |||||
| assetType: 'geometry' // dont set the value here since its checked in upgradeGeometry | |||||
| setDirty = iGeometryCommons.setDirty | |||||
| refreshUi = iGeometryCommons.refreshUi | |||||
| appliedMeshes = new Set<IObject3D>() | |||||
| constructor() { | |||||
| super() | |||||
| iGeometryCommons.upgradeGeometry.call(this) | |||||
| } | |||||
| } |
| function upgradeGeometry(this: IGeometry) { | function upgradeGeometry(this: IGeometry) { | ||||
| if (this.assetType === 'geometry') return // already upgraded | if (this.assetType === 'geometry') return // already upgraded | ||||
| if (!this.isBufferGeometry) { | if (!this.isBufferGeometry) { | ||||
| console.error('Geometry is not a this', this) | |||||
| console.error('Geometry is not a BufferGeometry', this) | |||||
| return | return | ||||
| } | } | ||||
| this.assetType = 'geometry' | this.assetType = 'geometry' |
| export {UnlitLineMaterial, type UnlitLineMaterialEventTypes, LineBasicMaterial2} from './material/UnlitLineMaterial' | export {UnlitLineMaterial, type UnlitLineMaterialEventTypes, LineBasicMaterial2} from './material/UnlitLineMaterial' | ||||
| export {LineMaterial2, type LineMaterial2EventTypes} from './material/LineMaterial2' | export {LineMaterial2, type LineMaterial2EventTypes} from './material/LineMaterial2' | ||||
| export {LegacyPhongMaterial, type PhongMaterialEventTypes} from './material/LegacyPhongMaterial' | export {LegacyPhongMaterial, type PhongMaterialEventTypes} from './material/LegacyPhongMaterial' | ||||
| export {BufferGeometry2} from './geometry/BufferGeometry2' | |||||
| export {iObjectCommons} from './object/iObjectCommons' | export {iObjectCommons} from './object/iObjectCommons' | ||||
| export {iCameraCommons} from './object/iCameraCommons' | export {iCameraCommons} from './object/iCameraCommons' | ||||
| export {iGeometryCommons} from './geometry/iGeometryCommons' | export {iGeometryCommons} from './geometry/iGeometryCommons' |
| // } | // } | ||||
| /** | /** | ||||
| * Add any processed object to the scene. | |||||
| * Add any object to the scene. | |||||
| * @param imported | * @param imported | ||||
| * @param options | * @param options | ||||
| */ | */ | ||||
| this.modelRoot.animations.push(animation) | this.modelRoot.animations.push(animation) | ||||
| } | } | ||||
| } | } | ||||
| return obj.children.map(c=>this.addObject(c, options)) | |||||
| return [...obj.children] // need to clone | |||||
| .map(c=>this.addObject(c, {...options, clearSceneObjects: false, disposeSceneObjects: false})) | |||||
| } | } | ||||
| private _addObject3D(model: IObject3D|null, {autoCenter = false, autoScale = false, autoScaleRadius = 2., addToRoot = false, license}: AddObjectOptions = {}): void { | private _addObject3D(model: IObject3D|null, {autoCenter = false, autoScale = false, autoScaleRadius = 2., addToRoot = false, license}: AddObjectOptions = {}): void { | ||||
| // new way | // new way | ||||
| const dist1 = Math.max(0.1, -this._v1.normalize().dot(camera.getWorldDirection(new Vector3()))) | const dist1 = Math.max(0.1, -this._v1.normalize().dot(camera.getWorldDirection(new Vector3()))) | ||||
| const near = Math.max(camera.userData.minNearPlane ?? 0.5, dist1 * (dist - radius)) | |||||
| const near = Math.max(Math.max(camera.userData.minNearPlane ?? 0.5, 0.001), dist1 * (dist - radius)) | |||||
| const far = Math.min(Math.max(near + radius, dist1 * (dist + radius)), camera.userData.maxFarPlane ?? 1000) | const far = Math.min(Math.max(near + radius, dist1 * (dist + radius)), camera.userData.maxFarPlane ?? 1000) | ||||
| // old way, has issues when panning very far from the camera target | // old way, has issues when panning very far from the camera target |