@xviewer.js/core 1.0.4 → 1.0.5-alhpa.0
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/main.cjs +29 -16
- package/dist/main.cjs.map +1 -1
- package/dist/module.js +29 -16
- package/dist/module.js.map +1 -1
- package/package.json +1 -1
- package/types/Viewer.d.ts +5 -2
- package/types/asset/ResourceManager.d.ts +5 -3
package/dist/main.cjs
CHANGED
|
@@ -4374,10 +4374,6 @@ class TaskManager {
|
|
|
4374
4374
|
}
|
|
4375
4375
|
add(task) {
|
|
4376
4376
|
this._tasks.push(task);
|
|
4377
|
-
if (this._onStartCalled === false) {
|
|
4378
|
-
this._onStartCalled = true;
|
|
4379
|
-
this.onStart && this.onStart();
|
|
4380
|
-
}
|
|
4381
4377
|
}
|
|
4382
4378
|
update() {
|
|
4383
4379
|
let task = this._tasks[this._taskIndex];
|
|
@@ -4388,6 +4384,10 @@ class TaskManager {
|
|
|
4388
4384
|
console.error(e);
|
|
4389
4385
|
this.onError && this.onError(task);
|
|
4390
4386
|
}
|
|
4387
|
+
if (this._onStartCalled === false) {
|
|
4388
|
+
this._onStartCalled = true;
|
|
4389
|
+
this.onStart && this.onStart();
|
|
4390
|
+
}
|
|
4391
4391
|
++this._taskIndex;
|
|
4392
4392
|
this.onProgress && this.onProgress(task, this._taskIndex, this._tasks.length);
|
|
4393
4393
|
if (this._taskIndex === this._tasks.length) {
|
|
@@ -4523,7 +4523,10 @@ class ResourceManager {
|
|
|
4523
4523
|
texSettings,
|
|
4524
4524
|
...props,
|
|
4525
4525
|
onProgress,
|
|
4526
|
-
onLoad:
|
|
4526
|
+
onLoad: (asset)=>{
|
|
4527
|
+
this._resources.set(url, asset);
|
|
4528
|
+
resolve(asset);
|
|
4529
|
+
},
|
|
4527
4530
|
onError: (err)=>{
|
|
4528
4531
|
console.error(`${url} not exist`, err);
|
|
4529
4532
|
reject(err);
|
|
@@ -4534,8 +4537,12 @@ class ResourceManager {
|
|
|
4534
4537
|
}
|
|
4535
4538
|
});
|
|
4536
4539
|
}
|
|
4540
|
+
getAsset(url) {
|
|
4541
|
+
return this._resources.get(url);
|
|
4542
|
+
}
|
|
4537
4543
|
constructor(viewer){
|
|
4538
4544
|
this._loaders = new Map();
|
|
4545
|
+
this._resources = new Map();
|
|
4539
4546
|
this._viewer = viewer;
|
|
4540
4547
|
}
|
|
4541
4548
|
}
|
|
@@ -4750,11 +4757,13 @@ class Viewer extends EventEmitter {
|
|
|
4750
4757
|
}
|
|
4751
4758
|
}
|
|
4752
4759
|
loop(dt) {
|
|
4753
|
-
this.
|
|
4754
|
-
|
|
4755
|
-
this.
|
|
4760
|
+
if (!this._loading) {
|
|
4761
|
+
this._taskManager.update();
|
|
4762
|
+
if (!this._tasking) {
|
|
4763
|
+
this._running = true;
|
|
4764
|
+
}
|
|
4756
4765
|
}
|
|
4757
|
-
if (this._running
|
|
4766
|
+
if (this._running) {
|
|
4758
4767
|
dt = Math.min(dt, 0.067);
|
|
4759
4768
|
this._renderer.info.reset();
|
|
4760
4769
|
this._componentManager.update(dt);
|
|
@@ -4774,8 +4783,7 @@ class Viewer extends EventEmitter {
|
|
|
4774
4783
|
return this;
|
|
4775
4784
|
}
|
|
4776
4785
|
stop() {
|
|
4777
|
-
this._active = false;
|
|
4778
|
-
this._running = 4;
|
|
4786
|
+
this._active = this._running = false;
|
|
4779
4787
|
this._time = this._lastTime = 0;
|
|
4780
4788
|
return this;
|
|
4781
4789
|
}
|
|
@@ -4857,8 +4865,13 @@ class Viewer extends EventEmitter {
|
|
|
4857
4865
|
setURLModifier(callback) {
|
|
4858
4866
|
return this._loadingManager.setURLModifier(callback);
|
|
4859
4867
|
}
|
|
4860
|
-
loadAsset(props) {
|
|
4861
|
-
return this._resourceManager.loadAsset(Object.assign({
|
|
4868
|
+
loadAsset({ url, ...props }) {
|
|
4869
|
+
return this._resourceManager.loadAsset(Object.assign({
|
|
4870
|
+
url: this._decodeURL(url)
|
|
4871
|
+
}, this._resourceOptions, props));
|
|
4872
|
+
}
|
|
4873
|
+
getAsset(url) {
|
|
4874
|
+
return this._resourceManager.getAsset(this._decodeURL(url));
|
|
4862
4875
|
}
|
|
4863
4876
|
getLoader(ext) {
|
|
4864
4877
|
return this._resourceManager.getLoader(ext);
|
|
@@ -5120,13 +5133,12 @@ class Viewer extends EventEmitter {
|
|
|
5120
5133
|
near: 0.1,
|
|
5121
5134
|
far: 1000,
|
|
5122
5135
|
position: new THREE.Vector3(0, 0, 4)
|
|
5123
|
-
}, targetFrameRate = -1, fixedFrameTime = false, colorSpace = THREE.SRGBColorSpace, toneMapping = THREE.LinearToneMapping, toneMappingExposure = 1, maxDPR = 1.5, path = "", resourcePath = "", dracoPath = "https://www.gstatic.com/draco/v1/decoders/", transcoderPath = "three/examples/js/libs/basis/", orientation = Orientation.AUTO, loader = {}, tasker = {}, ...webglOpts } = {}){
|
|
5136
|
+
}, targetFrameRate = -1, fixedFrameTime = false, colorSpace = THREE.SRGBColorSpace, toneMapping = THREE.LinearToneMapping, toneMappingExposure = 1, maxDPR = 1.5, path = "", resourcePath = "", dracoPath = "https://www.gstatic.com/draco/v1/decoders/", transcoderPath = "three/examples/js/libs/basis/", orientation = Orientation.AUTO, decodeURL = (url)=>url, loader = {}, tasker = {}, ...webglOpts } = {}){
|
|
5124
5137
|
super(), this._instanceId = Viewer.instanceCount++, this._dpr = 1, this._width = 1, this._height = 1, this._viewport = {
|
|
5125
5138
|
width: 1,
|
|
5126
5139
|
height: 1,
|
|
5127
5140
|
factor: 1
|
|
5128
|
-
}, this._active = false, this._loading = false, this._tasking = false, this._running =
|
|
5129
|
-
, this._rootRotated = false, this._time = 0, this._lastTime = 0, this._lastFrameTime = 0, this._targetFrameRate = -1, this._fixedFrameTime = false, this._windowSize = ()=>[
|
|
5141
|
+
}, this._active = false, this._loading = false, this._tasking = false, this._running = false, this._rootRotated = false, this._time = 0, this._lastTime = 0, this._lastFrameTime = 0, this._targetFrameRate = -1, this._fixedFrameTime = false, this._windowSize = ()=>[
|
|
5130
5142
|
window.innerWidth,
|
|
5131
5143
|
window.innerHeight
|
|
5132
5144
|
], this._orientation = Orientation.AUTO;
|
|
@@ -5181,6 +5193,7 @@ class Viewer extends EventEmitter {
|
|
|
5181
5193
|
this._input = this.add(new DeviceInput(input || {
|
|
5182
5194
|
source: this._canvas
|
|
5183
5195
|
}));
|
|
5196
|
+
this._decodeURL = decodeURL;
|
|
5184
5197
|
this.add(Renderer);
|
|
5185
5198
|
this.addLoader(GLTFLoader);
|
|
5186
5199
|
this.addLoader(HDRLoader);
|