@inweb/viewer-three 26.9.0 → 26.9.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/plugins/components/AxesHelperComponent.js +8 -6
- package/dist/plugins/components/AxesHelperComponent.js.map +1 -1
- package/dist/plugins/components/AxesHelperComponent.min.js +1 -1
- package/dist/plugins/components/AxesHelperComponent.module.js +7 -5
- package/dist/plugins/components/AxesHelperComponent.module.js.map +1 -1
- package/dist/plugins/loaders/IFCXLoader.js.map +1 -1
- package/dist/plugins/loaders/IFCXLoader.module.js.map +1 -1
- package/dist/plugins/loaders/PotreeLoader.js +160 -0
- package/dist/plugins/loaders/PotreeLoader.js.map +1 -0
- package/dist/plugins/loaders/PotreeLoader.min.js +1 -0
- package/dist/plugins/loaders/PotreeLoader.module.js +68 -0
- package/dist/plugins/loaders/PotreeLoader.module.js.map +1 -0
- package/dist/viewer-three.js +153 -110
- package/dist/viewer-three.js.map +1 -1
- package/dist/viewer-three.min.js +3 -3
- package/dist/viewer-three.module.js +152 -96
- package/dist/viewer-three.module.js.map +1 -1
- package/lib/Viewer/Viewer.d.ts +3 -2
- package/lib/Viewer/commands/SetDefaultViewPosition.d.ts +2 -2
- package/package.json +6 -5
- package/plugins/components/AxesHelperComponent.ts +10 -6
- package/plugins/loaders/{IFCXCloudLoader.ts → IFCX/IFCXCloudLoader.ts} +1 -1
- package/plugins/loaders/{IFCXFileLoader.ts → IFCX/IFCXFileLoader.ts} +1 -1
- package/plugins/loaders/Potree/PotreeFileLoader.ts +106 -0
- package/plugins/loaders/Potree/PotreeModelImpl.ts +36 -0
- package/plugins/loaders/Potree/index.ts +28 -0
- package/src/Viewer/Viewer.ts +39 -15
- package/src/Viewer/commands/SetDefaultViewPosition.ts +20 -16
- package/src/Viewer/commands/ZoomTo.ts +13 -13
- package/src/Viewer/components/ExtentsComponent.ts +1 -1
- package/src/Viewer/components/LightComponent.ts +8 -6
- package/src/Viewer/components/ResizeCanvasComponent.ts +1 -18
- package/src/Viewer/draggers/OrbitDragger.ts +9 -0
- package/src/Viewer/draggers/WalkDragger.ts +1 -0
- package/src/Viewer/helpers/WCSHelper.ts +3 -3
- package/src/Viewer/loaders/DynamicGltfLoader/DynamicGltfLoader.js +37 -12
- package/src/Viewer/loaders/DynamicGltfLoader/GltfStructure.js +32 -32
- package/src/Viewer/loaders/GLTFCloudDynamicLoader.ts +2 -2
- /package/plugins/loaders/{IFCXLoader.ts → IFCX/index.ts} +0 -0
|
@@ -785,6 +785,13 @@ class OrbitDragger {
|
|
|
785
785
|
this.viewer.target.copy(this.orbit.target);
|
|
786
786
|
this.viewer.update();
|
|
787
787
|
switch (this.orbit.state) {
|
|
788
|
+
case STATE.ROTATE:
|
|
789
|
+
case STATE.TOUCH_ROTATE:
|
|
790
|
+
this.viewer.emitEvent({
|
|
791
|
+
type: "orbit"
|
|
792
|
+
});
|
|
793
|
+
break;
|
|
794
|
+
|
|
788
795
|
case STATE.PAN:
|
|
789
796
|
case STATE.TOUCH_PAN:
|
|
790
797
|
this.viewer.emitEvent({
|
|
@@ -805,6 +812,9 @@ class OrbitDragger {
|
|
|
805
812
|
});
|
|
806
813
|
break;
|
|
807
814
|
}
|
|
815
|
+
this.viewer.emitEvent({
|
|
816
|
+
type: "changecamera"
|
|
817
|
+
});
|
|
808
818
|
this.changed = true;
|
|
809
819
|
};
|
|
810
820
|
this.stopContextMenu = event => {
|
|
@@ -1448,6 +1458,9 @@ class WalkDragger {
|
|
|
1448
1458
|
};
|
|
1449
1459
|
this.controlsChange = () => {
|
|
1450
1460
|
this.viewer.update();
|
|
1461
|
+
this.viewer.emitEvent({
|
|
1462
|
+
type: "changecamera"
|
|
1463
|
+
});
|
|
1451
1464
|
};
|
|
1452
1465
|
this.walkspeedChange = event => {
|
|
1453
1466
|
this.viewer.emitEvent(event);
|
|
@@ -1547,32 +1560,28 @@ function collect(viewer) {
|
|
|
1547
1560
|
|
|
1548
1561
|
function zoomTo(viewer, box) {
|
|
1549
1562
|
if (box.isEmpty()) return;
|
|
1550
|
-
const
|
|
1551
|
-
const
|
|
1563
|
+
const boxCenter = box.getCenter(new Vector3);
|
|
1564
|
+
const boxSize = box.getBoundingSphere(new Sphere).radius;
|
|
1552
1565
|
const rendererSize = viewer.renderer.getSize(new Vector2);
|
|
1553
1566
|
const aspect = rendererSize.x / rendererSize.y;
|
|
1554
1567
|
const camera = viewer.camera;
|
|
1555
1568
|
if (camera.isPerspectiveCamera) {
|
|
1556
|
-
const offset = new Vector3(0, 0, 1);
|
|
1557
|
-
offset.
|
|
1558
|
-
offset.multiplyScalar(sphere.radius / Math.tan(MathUtils.DEG2RAD * camera.fov * .5));
|
|
1559
|
-
camera.position.copy(center).add(offset);
|
|
1569
|
+
const offset = new Vector3(0, 0, 1).applyQuaternion(camera.quaternion).multiplyScalar(boxSize / Math.tan(MathUtils.DEG2RAD * camera.fov * .5));
|
|
1570
|
+
camera.position.copy(offset).add(boxCenter);
|
|
1560
1571
|
camera.updateMatrixWorld();
|
|
1561
1572
|
}
|
|
1562
1573
|
if (camera.isOrthographicCamera) {
|
|
1563
|
-
camera.top =
|
|
1564
|
-
camera.bottom = -
|
|
1574
|
+
camera.top = boxSize;
|
|
1575
|
+
camera.bottom = -boxSize;
|
|
1565
1576
|
camera.left = camera.bottom * aspect;
|
|
1566
1577
|
camera.right = camera.top * aspect;
|
|
1567
1578
|
camera.zoom = 1;
|
|
1568
1579
|
camera.updateProjectionMatrix();
|
|
1569
|
-
const offset = new Vector3(0, 0, 1);
|
|
1570
|
-
offset.
|
|
1571
|
-
offset.multiplyScalar(viewer.extents.getBoundingSphere(new Sphere).radius * 3);
|
|
1572
|
-
camera.position.copy(center).add(offset);
|
|
1580
|
+
const offset = new Vector3(0, 0, 1).applyQuaternion(camera.quaternion).multiplyScalar(viewer.extents.getBoundingSphere(new Sphere).radius * 3);
|
|
1581
|
+
camera.position.copy(offset).add(boxCenter);
|
|
1573
1582
|
camera.updateMatrixWorld();
|
|
1574
1583
|
}
|
|
1575
|
-
viewer.target.copy(
|
|
1584
|
+
viewer.target.copy(boxCenter);
|
|
1576
1585
|
viewer.update();
|
|
1577
1586
|
viewer.emitEvent({
|
|
1578
1587
|
type: "zoom"
|
|
@@ -1580,28 +1589,31 @@ function zoomTo(viewer, box) {
|
|
|
1580
1589
|
}
|
|
1581
1590
|
|
|
1582
1591
|
const defaultViewPositions = {
|
|
1583
|
-
front: new Vector3(0, 0, 1),
|
|
1584
|
-
back: new Vector3(0, 0,
|
|
1585
|
-
left: new Vector3(
|
|
1586
|
-
right: new Vector3(1, 0, 0),
|
|
1592
|
+
front: new Vector3(0, 0, -1),
|
|
1593
|
+
back: new Vector3(0, 0, 1),
|
|
1594
|
+
left: new Vector3(1, 0, 0),
|
|
1595
|
+
right: new Vector3(-1, 0, 0),
|
|
1587
1596
|
bottom: new Vector3(0, -1, 0),
|
|
1588
1597
|
top: new Vector3(0, 1, 0),
|
|
1589
|
-
|
|
1590
|
-
sw: new Vector3(
|
|
1591
|
-
|
|
1592
|
-
|
|
1598
|
+
se: new Vector3(-1, 1, -1).normalize(),
|
|
1599
|
+
sw: new Vector3(1, 1, -1).normalize(),
|
|
1600
|
+
ne: new Vector3(-1, 1, 1).normalize(),
|
|
1601
|
+
nw: new Vector3(1, 1, 1).normalize()
|
|
1593
1602
|
};
|
|
1594
1603
|
|
|
1595
1604
|
function setDefaultViewPosition(viewer, position) {
|
|
1596
|
-
const
|
|
1597
|
-
const
|
|
1598
|
-
const
|
|
1599
|
-
const
|
|
1605
|
+
const extentsCenter = viewer.extents.getCenter(new Vector3);
|
|
1606
|
+
const extentsSize = viewer.extents.getBoundingSphere(new Sphere).radius * 2;
|
|
1607
|
+
const upY = new Vector3(0, 1, 0);
|
|
1608
|
+
const offsetY = defaultViewPositions[position] || defaultViewPositions["sw"];
|
|
1609
|
+
const up = (new Vector3).copy(viewer.camera.up);
|
|
1610
|
+
const quaternion = (new Quaternion).setFromUnitVectors(upY, up);
|
|
1611
|
+
const offset = (new Vector3).copy(offsetY).applyQuaternion(quaternion);
|
|
1600
1612
|
const camera = viewer.camera;
|
|
1601
|
-
camera.position.copy(
|
|
1602
|
-
camera.lookAt(
|
|
1613
|
+
camera.position.copy(offset).multiplyScalar(extentsSize).add(extentsCenter);
|
|
1614
|
+
camera.lookAt(extentsCenter);
|
|
1603
1615
|
camera.updateMatrixWorld();
|
|
1604
|
-
viewer.target.copy(
|
|
1616
|
+
viewer.target.copy(extentsCenter);
|
|
1605
1617
|
viewer.update();
|
|
1606
1618
|
viewer.emit({
|
|
1607
1619
|
type: "viewposition",
|
|
@@ -1899,7 +1911,7 @@ class ExtentsComponent {
|
|
|
1899
1911
|
const extents = new Box3;
|
|
1900
1912
|
this.viewer.models.forEach((model => model.getExtents(extents)));
|
|
1901
1913
|
this.viewer.extents.copy(extents);
|
|
1902
|
-
extents.getCenter(this.viewer.target);
|
|
1914
|
+
this.viewer.extents.getCenter(this.viewer.target);
|
|
1903
1915
|
};
|
|
1904
1916
|
this.viewer = viewer;
|
|
1905
1917
|
this.viewer.addEventListener("databasechunk", this.syncExtents);
|
|
@@ -1931,8 +1943,12 @@ class LightComponent {
|
|
|
1931
1943
|
if (this.viewer.extents.isEmpty()) return;
|
|
1932
1944
|
const extentsCenter = this.viewer.extents.getCenter(new Vector3);
|
|
1933
1945
|
const extentsSize = this.viewer.extents.getBoundingSphere(new Sphere).radius;
|
|
1934
|
-
const
|
|
1935
|
-
|
|
1946
|
+
const upY = new Vector3(0, 1, 0);
|
|
1947
|
+
const frontY = new Vector3(0, 0, -1);
|
|
1948
|
+
const up = (new Vector3).copy(this.viewer.camera.up);
|
|
1949
|
+
const quaternion = (new Quaternion).setFromUnitVectors(upY, up);
|
|
1950
|
+
const front = (new Vector3).copy(frontY).applyQuaternion(quaternion).negate();
|
|
1951
|
+
this.directionalLight.position.copy(up).applyAxisAngle(front, -Math.PI * 30 / 180).multiplyScalar(extentsSize * 2).add(extentsCenter);
|
|
1936
1952
|
this.directionalLight.target.position.copy(extentsCenter);
|
|
1937
1953
|
this.frontLight.position.copy(front).multiplyScalar(extentsSize * 2).add(extentsCenter);
|
|
1938
1954
|
this.frontLight.target.position.copy(extentsCenter);
|
|
@@ -1987,25 +2003,7 @@ class ResizeCanvasComponent {
|
|
|
1987
2003
|
this.resizeViewer = entries => {
|
|
1988
2004
|
const {width: width, height: height} = entries[0].contentRect;
|
|
1989
2005
|
if (!width || !height) return;
|
|
1990
|
-
|
|
1991
|
-
const aspect = width / height;
|
|
1992
|
-
if (camera.isPerspectiveCamera) {
|
|
1993
|
-
camera.aspect = aspect;
|
|
1994
|
-
camera.updateProjectionMatrix();
|
|
1995
|
-
}
|
|
1996
|
-
if (camera.isOrthographicCamera) {
|
|
1997
|
-
camera.left = camera.bottom * aspect;
|
|
1998
|
-
camera.right = camera.top * aspect;
|
|
1999
|
-
camera.updateProjectionMatrix();
|
|
2000
|
-
}
|
|
2001
|
-
this.viewer.renderer.setSize(width, height, true);
|
|
2002
|
-
this.viewer.composer.setSize(width, height);
|
|
2003
|
-
this.viewer.update(true);
|
|
2004
|
-
this.viewer.emitEvent({
|
|
2005
|
-
type: "resize",
|
|
2006
|
-
width: width,
|
|
2007
|
-
height: height
|
|
2008
|
-
});
|
|
2006
|
+
this.viewer.setSize(width, height);
|
|
2009
2007
|
};
|
|
2010
2008
|
this.viewer = viewer;
|
|
2011
2009
|
this.resizeObserver = new ResizeObserver(this.resizeViewer);
|
|
@@ -2319,15 +2317,15 @@ class WCSHelper extends Object3D {
|
|
|
2319
2317
|
this.orthoCamera.position.set(0, 0, 2);
|
|
2320
2318
|
const matRed = new MeshBasicMaterial({
|
|
2321
2319
|
toneMapped: false,
|
|
2322
|
-
color: "#
|
|
2320
|
+
color: "#dd0000"
|
|
2323
2321
|
});
|
|
2324
2322
|
const matGreen = new MeshBasicMaterial({
|
|
2325
2323
|
toneMapped: false,
|
|
2326
|
-
color: "#
|
|
2324
|
+
color: "#00dd00"
|
|
2327
2325
|
});
|
|
2328
2326
|
const matBlue = new MeshBasicMaterial({
|
|
2329
2327
|
toneMapped: false,
|
|
2330
|
-
color: "#
|
|
2328
|
+
color: "#0000dd"
|
|
2331
2329
|
});
|
|
2332
2330
|
const spriteRed = this.getSpriteMaterial(matRed.color, "X");
|
|
2333
2331
|
const spriteGreen = this.getSpriteMaterial(matGreen.color, "Y");
|
|
@@ -2722,11 +2720,12 @@ const MAX_GAP = 128 * 1024;
|
|
|
2722
2720
|
const MAX_CHUNK = 30 * 1024 * 1024;
|
|
2723
2721
|
|
|
2724
2722
|
class GltfStructure {
|
|
2725
|
-
constructor(id) {
|
|
2723
|
+
constructor(id, loadController) {
|
|
2726
2724
|
this.id = `${id}`;
|
|
2727
2725
|
this.json = null;
|
|
2728
2726
|
this.baseUrl = "";
|
|
2729
|
-
this.loadController =
|
|
2727
|
+
this.loadController = loadController;
|
|
2728
|
+
this.loader = null;
|
|
2730
2729
|
this.batchDelay = 10;
|
|
2731
2730
|
this.maxBatchSize = 5 * 1024 * 1024;
|
|
2732
2731
|
this.maxRangesPerRequest = 512;
|
|
@@ -2737,10 +2736,10 @@ class GltfStructure {
|
|
|
2737
2736
|
this.textureCache = new Map;
|
|
2738
2737
|
this.materialCache = new Map;
|
|
2739
2738
|
}
|
|
2740
|
-
async initialize(
|
|
2741
|
-
this.json = await loadController.loadJson();
|
|
2742
|
-
this.baseUrl = await loadController.baseUrl();
|
|
2743
|
-
this.
|
|
2739
|
+
async initialize(loader) {
|
|
2740
|
+
this.json = await this.loadController.loadJson();
|
|
2741
|
+
this.baseUrl = await this.loadController.baseUrl();
|
|
2742
|
+
this.loader = loader;
|
|
2744
2743
|
}
|
|
2745
2744
|
clear() {
|
|
2746
2745
|
this.json = null;
|
|
@@ -2754,6 +2753,8 @@ class GltfStructure {
|
|
|
2754
2753
|
this.disposeMaterials();
|
|
2755
2754
|
this.textureCache.clear();
|
|
2756
2755
|
this.materials.clear();
|
|
2756
|
+
this.activeChunkLoads = 0;
|
|
2757
|
+
this.chunkQueue = [];
|
|
2757
2758
|
}
|
|
2758
2759
|
getJson() {
|
|
2759
2760
|
return this.json;
|
|
@@ -2831,23 +2832,33 @@ class GltfStructure {
|
|
|
2831
2832
|
});
|
|
2832
2833
|
}
|
|
2833
2834
|
}
|
|
2834
|
-
const promises = finalRanges.map((async range => {
|
|
2835
|
-
|
|
2836
|
-
|
|
2837
|
-
|
|
2838
|
-
|
|
2839
|
-
|
|
2840
|
-
|
|
2841
|
-
|
|
2842
|
-
|
|
2843
|
-
req.
|
|
2844
|
-
|
|
2845
|
-
|
|
2846
|
-
|
|
2847
|
-
|
|
2848
|
-
|
|
2849
|
-
|
|
2835
|
+
const promises = finalRanges.map((async (range, index) => {
|
|
2836
|
+
await this.loader.waitForChunkSlot();
|
|
2837
|
+
try {
|
|
2838
|
+
const length = range.end - range.start;
|
|
2839
|
+
const buffer = await this.loadController.loadBinaryData([ {
|
|
2840
|
+
offset: range.start,
|
|
2841
|
+
length: length
|
|
2842
|
+
} ]);
|
|
2843
|
+
for (const req of range.requests) {
|
|
2844
|
+
const relOffset = req.offset - range.start;
|
|
2845
|
+
try {
|
|
2846
|
+
req._resolve({
|
|
2847
|
+
buffer: buffer,
|
|
2848
|
+
relOffset: relOffset,
|
|
2849
|
+
length: req.length
|
|
2850
|
+
});
|
|
2851
|
+
} catch (e) {
|
|
2852
|
+
req._reject(e);
|
|
2853
|
+
}
|
|
2854
|
+
}
|
|
2855
|
+
} catch (error) {
|
|
2856
|
+
for (const req of range.requests) {
|
|
2857
|
+
req._reject(error);
|
|
2850
2858
|
}
|
|
2859
|
+
console.warn(`Failed to load chunk ${index + 1}/${finalRanges.length} (${range.start}-${range.end}):`, error);
|
|
2860
|
+
} finally {
|
|
2861
|
+
this.loader.releaseChunkSlot();
|
|
2851
2862
|
}
|
|
2852
2863
|
}));
|
|
2853
2864
|
await Promise.all(promises);
|
|
@@ -3207,6 +3218,9 @@ class DynamicGltfLoader {
|
|
|
3207
3218
|
this.hiddenHandles = new Set;
|
|
3208
3219
|
this.newOptimizedObjects = new Set;
|
|
3209
3220
|
this.oldOptimizeObjects = new Set;
|
|
3221
|
+
this.maxConcurrentChunks = 8;
|
|
3222
|
+
this.activeChunkLoads = 0;
|
|
3223
|
+
this.chunkQueue = [];
|
|
3210
3224
|
}
|
|
3211
3225
|
setVisibleEdges(visible) {
|
|
3212
3226
|
this.visibleEdges = visible;
|
|
@@ -3564,6 +3578,7 @@ class DynamicGltfLoader {
|
|
|
3564
3578
|
this.clear();
|
|
3565
3579
|
const structureArray = Array.isArray(structures) ? structures : [ structures ];
|
|
3566
3580
|
for (const structure of structureArray) {
|
|
3581
|
+
await structure.initialize(this);
|
|
3567
3582
|
this.structures.push(structure);
|
|
3568
3583
|
}
|
|
3569
3584
|
for (const structure of this.structures) {
|
|
@@ -3875,12 +3890,6 @@ class DynamicGltfLoader {
|
|
|
3875
3890
|
clearNodesToLoad() {
|
|
3876
3891
|
this.nodesToLoad = [];
|
|
3877
3892
|
}
|
|
3878
|
-
async addStructure(loadController) {
|
|
3879
|
-
const structure = new GltfStructure;
|
|
3880
|
-
await structure.initialize(loadController);
|
|
3881
|
-
this.structures.push(structure);
|
|
3882
|
-
return structure;
|
|
3883
|
-
}
|
|
3884
3893
|
removeOptimization() {
|
|
3885
3894
|
this.originalObjects.forEach((obj => obj.visible = true));
|
|
3886
3895
|
const disposeMerged = obj => {
|
|
@@ -3909,6 +3918,7 @@ class DynamicGltfLoader {
|
|
|
3909
3918
|
this.originalObjectsToSelection.clear();
|
|
3910
3919
|
}
|
|
3911
3920
|
clear() {
|
|
3921
|
+
this.chunkQueue = [];
|
|
3912
3922
|
this.structures.forEach((structure => {
|
|
3913
3923
|
if (structure) {
|
|
3914
3924
|
structure.clear();
|
|
@@ -4596,6 +4606,30 @@ class DynamicGltfLoader {
|
|
|
4596
4606
|
}
|
|
4597
4607
|
return extent;
|
|
4598
4608
|
}
|
|
4609
|
+
setMaxConcurrentChunks(maxChunks) {
|
|
4610
|
+
if (maxChunks < 1) {
|
|
4611
|
+
console.warn("Max concurrent chunks must be at least 1");
|
|
4612
|
+
return;
|
|
4613
|
+
}
|
|
4614
|
+
this.maxConcurrentChunks = maxChunks;
|
|
4615
|
+
}
|
|
4616
|
+
waitForChunkSlot() {
|
|
4617
|
+
if (this.activeChunkLoads < this.maxConcurrentChunks) {
|
|
4618
|
+
this.activeChunkLoads++;
|
|
4619
|
+
return Promise.resolve();
|
|
4620
|
+
}
|
|
4621
|
+
return new Promise((resolve => {
|
|
4622
|
+
this.chunkQueue.push(resolve);
|
|
4623
|
+
}));
|
|
4624
|
+
}
|
|
4625
|
+
releaseChunkSlot() {
|
|
4626
|
+
this.activeChunkLoads--;
|
|
4627
|
+
if (this.chunkQueue.length > 0) {
|
|
4628
|
+
const nextResolve = this.chunkQueue.shift();
|
|
4629
|
+
this.activeChunkLoads++;
|
|
4630
|
+
nextResolve();
|
|
4631
|
+
}
|
|
4632
|
+
}
|
|
4599
4633
|
}
|
|
4600
4634
|
|
|
4601
4635
|
class GLTFCloudDynamicLoader {
|
|
@@ -4676,8 +4710,7 @@ class GLTFCloudDynamicLoader {
|
|
|
4676
4710
|
},
|
|
4677
4711
|
baseUrl: () => Promise.resolve(`${model.httpClient.serverUrl}${model.path}/`)
|
|
4678
4712
|
};
|
|
4679
|
-
const structure = new GltfStructure(model.id);
|
|
4680
|
-
await structure.initialize(loadController);
|
|
4713
|
+
const structure = new GltfStructure(model.id, loadController);
|
|
4681
4714
|
await this.gltfLoader.loadStructure(structure);
|
|
4682
4715
|
await this.gltfLoader.loadNodes();
|
|
4683
4716
|
return this;
|
|
@@ -4821,7 +4854,7 @@ class Viewer extends EventEmitter2 {
|
|
|
4821
4854
|
this.target = new Vector3;
|
|
4822
4855
|
this._activeDragger = null;
|
|
4823
4856
|
this._components = [];
|
|
4824
|
-
this.
|
|
4857
|
+
this._renderTime = 0;
|
|
4825
4858
|
this.render = this.render.bind(this);
|
|
4826
4859
|
this.update = this.update.bind(this);
|
|
4827
4860
|
this._markup = new Markup;
|
|
@@ -4842,13 +4875,13 @@ class Viewer extends EventEmitter2 {
|
|
|
4842
4875
|
this.addEventListener("optionschange", (event => this.syncOptions(event.data)));
|
|
4843
4876
|
this.scene = new Scene;
|
|
4844
4877
|
this.helpers = new Helpers;
|
|
4845
|
-
this.target = new Vector3;
|
|
4878
|
+
this.target = new Vector3(0, 0, 0);
|
|
4846
4879
|
const pixelRatio = window.devicePixelRatio;
|
|
4847
4880
|
const rect = canvas.parentElement.getBoundingClientRect();
|
|
4848
4881
|
const width = rect.width || 1;
|
|
4849
4882
|
const height = rect.height || 1;
|
|
4850
4883
|
const aspect = width / height;
|
|
4851
|
-
this.camera = new PerspectiveCamera(45, aspect, .
|
|
4884
|
+
this.camera = new PerspectiveCamera(45, aspect, .001, 1e3);
|
|
4852
4885
|
this.camera.up.set(0, 1, 0);
|
|
4853
4886
|
this.camera.position.set(0, 0, 1);
|
|
4854
4887
|
this.camera.lookAt(this.target);
|
|
@@ -4879,6 +4912,7 @@ class Viewer extends EventEmitter2 {
|
|
|
4879
4912
|
this.composer.addPass(this.fxaaPass);
|
|
4880
4913
|
this.composer.addPass(this.ssaaRenderPass);
|
|
4881
4914
|
this.composer.addPass(this.outputPass);
|
|
4915
|
+
this.composer.setSize(width, height);
|
|
4882
4916
|
this.canvas = canvas;
|
|
4883
4917
|
this.canvasEvents.forEach((x => canvas.addEventListener(x, this.canvaseventlistener)));
|
|
4884
4918
|
this._markup.initialize(this.canvas, this.canvasEvents, this, this);
|
|
@@ -4887,8 +4921,8 @@ class Viewer extends EventEmitter2 {
|
|
|
4887
4921
|
}
|
|
4888
4922
|
this.syncOptions();
|
|
4889
4923
|
this.syncOverlay();
|
|
4890
|
-
this.
|
|
4891
|
-
this.render(this.
|
|
4924
|
+
this._renderTime = performance.now();
|
|
4925
|
+
this.render(this._renderTime);
|
|
4892
4926
|
if (typeof onProgress === "function") onProgress(new ProgressEvent("progress", {
|
|
4893
4927
|
lengthComputable: true,
|
|
4894
4928
|
loaded: 1,
|
|
@@ -4944,8 +4978,30 @@ class Viewer extends EventEmitter2 {
|
|
|
4944
4978
|
isInitialized() {
|
|
4945
4979
|
return !!this.renderer;
|
|
4946
4980
|
}
|
|
4981
|
+
setSize(width, height, updateStyle = true) {
|
|
4982
|
+
if (!this.renderer) return;
|
|
4983
|
+
const camera = this.camera;
|
|
4984
|
+
const aspect = width / height;
|
|
4985
|
+
if (camera.isPerspectiveCamera) {
|
|
4986
|
+
camera.aspect = aspect;
|
|
4987
|
+
camera.updateProjectionMatrix();
|
|
4988
|
+
}
|
|
4989
|
+
if (camera.isOrthographicCamera) {
|
|
4990
|
+
camera.left = camera.bottom * aspect;
|
|
4991
|
+
camera.right = camera.top * aspect;
|
|
4992
|
+
camera.updateProjectionMatrix();
|
|
4993
|
+
}
|
|
4994
|
+
this.renderer.setSize(width, height, updateStyle);
|
|
4995
|
+
this.composer.setSize(width, height);
|
|
4996
|
+
this.update(true);
|
|
4997
|
+
this.emitEvent({
|
|
4998
|
+
type: "resize",
|
|
4999
|
+
width: width,
|
|
5000
|
+
height: height
|
|
5001
|
+
});
|
|
5002
|
+
}
|
|
4947
5003
|
update(force = false) {
|
|
4948
|
-
this.
|
|
5004
|
+
this._renderNeeded = true;
|
|
4949
5005
|
if (force) this.render();
|
|
4950
5006
|
this.emitEvent({
|
|
4951
5007
|
type: "update",
|
|
@@ -4955,11 +5011,11 @@ class Viewer extends EventEmitter2 {
|
|
|
4955
5011
|
render(time, force = false) {
|
|
4956
5012
|
var _a, _b;
|
|
4957
5013
|
if (!this.renderer) return;
|
|
4958
|
-
if (!
|
|
5014
|
+
if (!this._renderNeeded && !force) return;
|
|
4959
5015
|
if (!time) time = performance.now();
|
|
4960
|
-
const deltaTime = (time - this.
|
|
4961
|
-
this.
|
|
4962
|
-
this.
|
|
5016
|
+
const deltaTime = (time - this._renderTime) / 1e3;
|
|
5017
|
+
this._renderTime = time;
|
|
5018
|
+
this._renderNeeded = false;
|
|
4963
5019
|
if (this.options.antialiasing === true || this.options.antialiasing === "msaa") {
|
|
4964
5020
|
this.renderer.render(this.scene, this.camera);
|
|
4965
5021
|
this.renderer.render(this.helpers, this.camera);
|
|
@@ -5217,7 +5273,7 @@ class Viewer extends EventEmitter2 {
|
|
|
5217
5273
|
camera.left = camera.bottom * aspect;
|
|
5218
5274
|
camera.right = camera.top * aspect;
|
|
5219
5275
|
camera.near = 0;
|
|
5220
|
-
camera.far = extentsSize *
|
|
5276
|
+
camera.far = extentsSize * 1e3;
|
|
5221
5277
|
camera.zoom = orthogonal_camera.view_to_world_scale;
|
|
5222
5278
|
camera.updateProjectionMatrix();
|
|
5223
5279
|
camera.up.copy(getVector3FromPoint3d(orthogonal_camera.up_vector));
|
|
@@ -5238,8 +5294,8 @@ class Viewer extends EventEmitter2 {
|
|
|
5238
5294
|
const camera = new PerspectiveCamera;
|
|
5239
5295
|
camera.fov = perspective_camera.field_of_view;
|
|
5240
5296
|
camera.aspect = aspect;
|
|
5241
|
-
camera.near = extentsSize /
|
|
5242
|
-
camera.far = extentsSize *
|
|
5297
|
+
camera.near = extentsSize / 1e3;
|
|
5298
|
+
camera.far = extentsSize * 1e3;
|
|
5243
5299
|
camera.updateProjectionMatrix();
|
|
5244
5300
|
camera.up.copy(getVector3FromPoint3d(perspective_camera.up_vector));
|
|
5245
5301
|
camera.position.copy(getVector3FromPoint3d(perspective_camera.view_point));
|