Rename viewer geometry to viewer model.

This commit is contained in:
kovacsv 2022-12-19 14:16:49 +01:00
parent c8b5757338
commit 69b423e837
4 changed files with 33 additions and 33 deletions

View File

@ -69,7 +69,7 @@ import { GetIntegerFromStyle, GetDomElementExternalWidth, GetDomElementExternalH
import { EmbeddedViewer, Init3DViewerElement, Init3DViewerElements } from './viewer/embeddedviewer.js';
import { MouseInteraction, TouchInteraction, ClickDetector, Navigation, NavigationType } from './viewer/navigation.js';
import { CameraValidator, UpVector, ShadingModel, Viewer, GetDefaultCamera, TraverseThreeObject, GetShadingTypeOfObject, CameraMode } from './viewer/viewer.js';
import { ViewerGeometry, ViewerExtraGeometry, SetThreeMeshPolygonOffset } from './viewer/viewergeometry.js';
import { ViewerModel, ViewerMainModel, SetThreeMeshPolygonOffset } from './viewer/viewermodel.js';
export {
IsDefined,
@ -325,7 +325,7 @@ export {
TraverseThreeObject,
GetShadingTypeOfObject,
CameraMode,
ViewerGeometry,
ViewerExtraGeometry,
ViewerModel,
ViewerMainModel,
SetThreeMeshPolygonOffset
};

View File

@ -190,7 +190,6 @@ export function DisposeThreeObjects (mainObject)
mainObject.traverse ((obj) => {
if (obj.isMesh || obj.isLineSegments) {
obj.geometry.dispose ();
if (Array.isArray (obj.material)) {
for (let material of obj.material) {
material.dispose ();
@ -198,6 +197,7 @@ export function DisposeThreeObjects (mainObject)
} else {
obj.material.dispose ();
}
obj.geometry.dispose ();
}
});
}

View File

@ -5,7 +5,7 @@ import { ShadingType } from '../threejs/threeutils.js';
import { Camera } from './camera.js';
import { GetDomElementInnerDimensions } from './domutils.js';
import { Navigation } from './navigation.js';
import { ViewerExtraGeometry, ViewerGeometry } from './viewergeometry.js';
import { ViewerModel, ViewerMainModel } from './viewermodel.js';
import * as THREE from 'three';
@ -283,8 +283,8 @@ export class Viewer
this.renderer.setSize (this.canvas.width, this.canvas.height);
this.scene = new THREE.Scene ();
this.geometry = new ViewerGeometry (this.scene);
this.extraGeometry = new ViewerExtraGeometry (this.scene);
this.geometry = new ViewerMainModel (this.scene);
this.extraGeometry = new ViewerModel (this.scene);
this.InitNavigation ();
this.InitShading ();

View File

@ -20,7 +20,32 @@ export function SetThreeMeshPolygonOffset (mesh, offset)
}
}
export class ViewerGeometry
export class ViewerModel
{
constructor (scene)
{
this.scene = scene;
this.mainObject = null;
}
AddObject (object)
{
if (this.mainObject === null) {
this.mainObject = new THREE.Object3D ();
this.scene.add (this.mainObject);
}
this.mainObject.add (object);
}
Clear ()
{
DisposeThreeObjects (this.mainObject);
this.scene.remove (this.mainObject);
this.mainObject = null;
}
}
export class ViewerMainModel
{
constructor (scene)
{
@ -212,28 +237,3 @@ export class ViewerGeometry
return null;
}
}
export class ViewerExtraGeometry
{
constructor (scene)
{
this.scene = scene;
this.mainObject = null;
}
AddObject (object)
{
if (this.mainObject === null) {
this.mainObject = new THREE.Object3D ();
this.scene.add (this.mainObject);
}
this.mainObject.add (object);
}
Clear ()
{
DisposeThreeObjects (this.mainObject);
this.scene.remove (this.mainObject);
this.mainObject = null;
}
}