| @@ -137,6 +137,7 @@ export interface IMaterial<E extends IMaterialEvent = IMaterialEvent, ET = IMate | |||
| color?: Color | |||
| wireframe?: boolean | |||
| linewidth?: number | |||
| isRawShaderMaterial?: boolean | |||
| isPhysicalMaterial?: boolean | |||
| @@ -0,0 +1,17 @@ | |||
| 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) | |||
| } | |||
| } | |||
| @@ -148,7 +148,7 @@ export const iGeometryCommons = { | |||
| function upgradeGeometry(this: IGeometry) { | |||
| if (this.assetType === 'geometry') return // already upgraded | |||
| if (!this.isBufferGeometry) { | |||
| console.error('Geometry is not a this', this) | |||
| console.error('Geometry is not a BufferGeometry', this) | |||
| return | |||
| } | |||
| this.assetType = 'geometry' | |||
| @@ -7,6 +7,7 @@ export {UnlitMaterial, type UnlitMaterialEventTypes, MeshBasicMaterial2} from '. | |||
| export {UnlitLineMaterial, type UnlitLineMaterialEventTypes, LineBasicMaterial2} from './material/UnlitLineMaterial' | |||
| export {LineMaterial2, type LineMaterial2EventTypes} from './material/LineMaterial2' | |||
| export {LegacyPhongMaterial, type PhongMaterialEventTypes} from './material/LegacyPhongMaterial' | |||
| export {BufferGeometry2} from './geometry/BufferGeometry2' | |||
| export {iObjectCommons} from './object/iObjectCommons' | |||
| export {iCameraCommons} from './object/iCameraCommons' | |||
| export {iGeometryCommons} from './geometry/iGeometryCommons' | |||
| @@ -166,7 +166,7 @@ export class RootScene extends Scene<ISceneEvent, ISceneEventTypes> implements I | |||
| // } | |||
| /** | |||
| * Add any processed object to the scene. | |||
| * Add any object to the scene. | |||
| * @param imported | |||
| * @param options | |||
| */ | |||
| @@ -223,7 +223,8 @@ export class RootScene extends Scene<ISceneEvent, ISceneEventTypes> implements I | |||
| 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 { | |||
| @@ -408,7 +409,7 @@ export class RootScene extends Scene<ISceneEvent, ISceneEventTypes> implements I | |||
| // new way | |||
| 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) | |||
| // old way, has issues when panning very far from the camera target | |||