@xviewer.js/core 1.0.0-alpha.4 → 1.0.0-alpha.6
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.js +30 -131
- package/dist/main.js.map +1 -1
- package/dist/module.js +31 -132
- package/dist/module.js.map +1 -1
- package/package.json +1 -1
package/dist/main.js
CHANGED
|
@@ -1065,22 +1065,6 @@ class aLoader {
|
|
|
1065
1065
|
}
|
|
1066
1066
|
}
|
|
1067
1067
|
|
|
1068
|
-
function _object_without_properties_loose(source, excluded) {
|
|
1069
|
-
if (source == null) return {};
|
|
1070
|
-
|
|
1071
|
-
var target = {};
|
|
1072
|
-
var sourceKeys = Object.keys(source);
|
|
1073
|
-
var key, i;
|
|
1074
|
-
|
|
1075
|
-
for (i = 0; i < sourceKeys.length; i++) {
|
|
1076
|
-
key = sourceKeys[i];
|
|
1077
|
-
if (excluded.indexOf(key) >= 0) continue;
|
|
1078
|
-
target[key] = source[key];
|
|
1079
|
-
}
|
|
1080
|
-
|
|
1081
|
-
return target;
|
|
1082
|
-
}
|
|
1083
|
-
|
|
1084
1068
|
class ResourceManager {
|
|
1085
1069
|
static extension(path) {
|
|
1086
1070
|
let str = path.split(".");
|
|
@@ -1150,12 +1134,7 @@ class ResourceManager {
|
|
|
1150
1134
|
destroy() {
|
|
1151
1135
|
this._caches.clear();
|
|
1152
1136
|
}
|
|
1153
|
-
loadAsset(
|
|
1154
|
-
var { url, ext, onProgress } = _param, props = _object_without_properties_loose(_param, [
|
|
1155
|
-
"url",
|
|
1156
|
-
"ext",
|
|
1157
|
-
"onProgress"
|
|
1158
|
-
]);
|
|
1137
|
+
loadAsset({ url, ext, onProgress, ...props }) {
|
|
1159
1138
|
return new Promise((resolve, reject)=>{
|
|
1160
1139
|
const info = ResourceManager._parseURL(url);
|
|
1161
1140
|
const texSettings = ResourceManager._splitTextureSettings(props);
|
|
@@ -6764,7 +6743,7 @@ class aGLTFLoader extends aLoader {
|
|
|
6764
6743
|
if (gltf.animations) node.animations = gltf.animations;
|
|
6765
6744
|
onLoad(aLoader._setMeshData(node));
|
|
6766
6745
|
};
|
|
6767
|
-
let gltfLoader = new GLTFLoader(this.loadingManager);
|
|
6746
|
+
let gltfLoader = new GLTFLoader(this.manager.loadingManager);
|
|
6768
6747
|
gltfLoader.setPath(this.manager.path);
|
|
6769
6748
|
gltfLoader.setResourcePath(this.manager.resourcePath);
|
|
6770
6749
|
let dracoLoader = new DRACOLoader(this.manager.loadingManager);
|
|
@@ -13203,11 +13182,10 @@ const Vector3_ZERO = new three.Vector3();
|
|
|
13203
13182
|
|
|
13204
13183
|
const { clamp, degToRad } = three.MathUtils;
|
|
13205
13184
|
const { abs, tan } = Math;
|
|
13206
|
-
|
|
13207
|
-
|
|
13208
|
-
|
|
13209
|
-
|
|
13210
|
-
})(VCamFreeLookMode || (VCamFreeLookMode = {}));
|
|
13185
|
+
const VCamFreeLookMode = {
|
|
13186
|
+
FREE: 0,
|
|
13187
|
+
TRANSLATE: 1
|
|
13188
|
+
};
|
|
13211
13189
|
class FreelookVirtualCamera extends VirtualCamera {
|
|
13212
13190
|
onEnable() {
|
|
13213
13191
|
this.viewer.on(DeviceInput.POINTER_DOWN, this._onPointerDown, this);
|
|
@@ -13346,7 +13324,7 @@ class FreelookVirtualCamera extends VirtualCamera {
|
|
|
13346
13324
|
const { __posDelta, __posOffset, __worldPos, __quat, __spherical, __xAxis, __yAxis } = FreelookVirtualCamera;
|
|
13347
13325
|
__worldPos.copy(this.lookAt.position).add(this.trackedObjectOffset);
|
|
13348
13326
|
switch(this.mode){
|
|
13349
|
-
case
|
|
13327
|
+
case VCamFreeLookMode.FREE:
|
|
13350
13328
|
if (abs(this._rotateDelta.x) + abs(this._rotateDelta.y) + abs(this._distanceDelta) > 0.001) {
|
|
13351
13329
|
const { __posDelta, __posOffset, __worldPos } = FreelookVirtualCamera;
|
|
13352
13330
|
__quat.setFromUnitVectors(this.node.up, three.Object3D.DEFAULT_UP);
|
|
@@ -13367,7 +13345,7 @@ class FreelookVirtualCamera extends VirtualCamera {
|
|
|
13367
13345
|
this.node.position.copy(__posDelta.add(__worldPos));
|
|
13368
13346
|
}
|
|
13369
13347
|
break;
|
|
13370
|
-
case
|
|
13348
|
+
case VCamFreeLookMode.TRANSLATE:
|
|
13371
13349
|
if (abs(this._distanceDelta) > 0.001) {
|
|
13372
13350
|
__posDelta.copy(this.node.position).sub(this.lookAt.position);
|
|
13373
13351
|
let dampFactor = quarticDamp(1, 0, this.rotateSmoothing, dt);
|
|
@@ -13411,7 +13389,7 @@ class FreelookVirtualCamera extends VirtualCamera {
|
|
|
13411
13389
|
this._preLoc1 = new three.Vector2();
|
|
13412
13390
|
this._rotateDelta = new three.Vector2();
|
|
13413
13391
|
this._panDelta = new three.Vector2();
|
|
13414
|
-
this.mode =
|
|
13392
|
+
this.mode = VCamFreeLookMode.FREE;
|
|
13415
13393
|
this.forbidX = false;
|
|
13416
13394
|
this.forbidY = false;
|
|
13417
13395
|
this.forbidZ = false;
|
|
@@ -13467,10 +13445,7 @@ FreelookVirtualCamera.__quat = new three.Quaternion();
|
|
|
13467
13445
|
FreelookVirtualCamera.__spherical = new three.Spherical();
|
|
13468
13446
|
__decorate([
|
|
13469
13447
|
property({
|
|
13470
|
-
value:
|
|
13471
|
-
FREE: 0,
|
|
13472
|
-
TRANSLATE: 1
|
|
13473
|
-
}
|
|
13448
|
+
value: VCamFreeLookMode
|
|
13474
13449
|
})
|
|
13475
13450
|
], FreelookVirtualCamera.prototype, "mode", void 0);
|
|
13476
13451
|
__decorate([
|
|
@@ -13522,37 +13497,6 @@ class Plane extends three.Mesh {
|
|
|
13522
13497
|
}
|
|
13523
13498
|
}
|
|
13524
13499
|
|
|
13525
|
-
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
13526
|
-
try {
|
|
13527
|
-
var info = gen[key](arg);
|
|
13528
|
-
var value = info.value;
|
|
13529
|
-
} catch (error) {
|
|
13530
|
-
reject(error);
|
|
13531
|
-
return;
|
|
13532
|
-
}
|
|
13533
|
-
if (info.done) resolve(value);
|
|
13534
|
-
else Promise.resolve(value).then(_next, _throw);
|
|
13535
|
-
}
|
|
13536
|
-
function _async_to_generator(fn) {
|
|
13537
|
-
return function() {
|
|
13538
|
-
var self = this, args = arguments;
|
|
13539
|
-
|
|
13540
|
-
return new Promise(function(resolve, reject) {
|
|
13541
|
-
var gen = fn.apply(self, args);
|
|
13542
|
-
|
|
13543
|
-
function _next(value) {
|
|
13544
|
-
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
13545
|
-
}
|
|
13546
|
-
|
|
13547
|
-
function _throw(err) {
|
|
13548
|
-
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
13549
|
-
}
|
|
13550
|
-
|
|
13551
|
-
_next(undefined);
|
|
13552
|
-
});
|
|
13553
|
-
};
|
|
13554
|
-
}
|
|
13555
|
-
|
|
13556
13500
|
class Caller {
|
|
13557
13501
|
get pause() {
|
|
13558
13502
|
return this._pause;
|
|
@@ -14284,30 +14228,20 @@ class Viewer extends EventEmitter {
|
|
|
14284
14228
|
loadAsset(props) {
|
|
14285
14229
|
return this._resourceManager.loadAsset(props);
|
|
14286
14230
|
}
|
|
14287
|
-
load(
|
|
14288
|
-
|
|
14289
|
-
|
|
14290
|
-
|
|
14291
|
-
|
|
14292
|
-
|
|
14293
|
-
|
|
14294
|
-
|
|
14295
|
-
|
|
14296
|
-
|
|
14297
|
-
const node = yield _this.loadAsset({
|
|
14298
|
-
url,
|
|
14299
|
-
ext,
|
|
14300
|
-
onProgress
|
|
14231
|
+
async load({ url, ext, onProgress, castShadow = false, receiveShadow = false, ...props }) {
|
|
14232
|
+
const node = await this.loadAsset({
|
|
14233
|
+
url,
|
|
14234
|
+
ext,
|
|
14235
|
+
onProgress
|
|
14236
|
+
});
|
|
14237
|
+
if (castShadow || receiveShadow) {
|
|
14238
|
+
node.userData.meshData.meshes.forEach((v)=>{
|
|
14239
|
+
v.castShadow = castShadow;
|
|
14240
|
+
v.receiveShadow = receiveShadow;
|
|
14301
14241
|
});
|
|
14302
|
-
|
|
14303
|
-
|
|
14304
|
-
|
|
14305
|
-
v.receiveShadow = receiveShadow;
|
|
14306
|
-
});
|
|
14307
|
-
}
|
|
14308
|
-
_this.addNode(node, props);
|
|
14309
|
-
return node;
|
|
14310
|
-
})();
|
|
14242
|
+
}
|
|
14243
|
+
this.addNode(node, props);
|
|
14244
|
+
return node;
|
|
14311
14245
|
}
|
|
14312
14246
|
tween(target) {
|
|
14313
14247
|
return this._tweenManager.tween(target);
|
|
@@ -14356,18 +14290,7 @@ class Viewer extends EventEmitter {
|
|
|
14356
14290
|
removeComponent(node, component) {
|
|
14357
14291
|
return this._componentManager.removeComponent(node, component);
|
|
14358
14292
|
}
|
|
14359
|
-
addNode(object,
|
|
14360
|
-
var { args, debug, scale, position, rotation, shadowArgs, makeDefault, component, parent = this._scene } = _param, props = _object_without_properties_loose(_param, [
|
|
14361
|
-
"args",
|
|
14362
|
-
"debug",
|
|
14363
|
-
"scale",
|
|
14364
|
-
"position",
|
|
14365
|
-
"rotation",
|
|
14366
|
-
"shadowArgs",
|
|
14367
|
-
"makeDefault",
|
|
14368
|
-
"component",
|
|
14369
|
-
"parent"
|
|
14370
|
-
]);
|
|
14293
|
+
addNode(object, { args, debug, scale, position, rotation, shadowArgs, makeDefault, component, parent = this._scene, ...props } = {}) {
|
|
14371
14294
|
let node = null;
|
|
14372
14295
|
let ins = Viewer._getClassInstance(object, args);
|
|
14373
14296
|
if (ins.isObject3D) {
|
|
@@ -14415,12 +14338,6 @@ class Viewer extends EventEmitter {
|
|
|
14415
14338
|
this._componentManager.activeComponents(node);
|
|
14416
14339
|
node.visible = active;
|
|
14417
14340
|
}
|
|
14418
|
-
createComponent(comp, _param = {}) {
|
|
14419
|
-
var { args } = _param, props = _object_without_properties_loose(_param, [
|
|
14420
|
-
"args"
|
|
14421
|
-
]);
|
|
14422
|
-
return applyProps(Viewer._getClassInstance(comp, args), props);
|
|
14423
|
-
}
|
|
14424
14341
|
createRenderTarget(width, height, nearest = false, floatType = false, msaa = 0, mipmap = false) {
|
|
14425
14342
|
return new three.WebGLRenderTarget(width, height, {
|
|
14426
14343
|
wrapS: three.ClampToEdgeWrapping,
|
|
@@ -14494,30 +14411,12 @@ class Viewer extends EventEmitter {
|
|
|
14494
14411
|
Viewer.CompileObject3D(this._renderer, this._scene, this._camera, this._scene);
|
|
14495
14412
|
}
|
|
14496
14413
|
}
|
|
14497
|
-
constructor(
|
|
14498
|
-
|
|
14499
|
-
|
|
14500
|
-
|
|
14501
|
-
|
|
14502
|
-
|
|
14503
|
-
}, targetFrameRate = -1, colorSpace = three.SRGBColorSpace, toneMapping = three.LinearToneMapping, toneMappingExposure = 1, maxDPR = 1.5, path = "", resourcePath = "", dracoPath = "https://www.gstatic.com/draco/v1/decoders/", loader = {}, tasker = {} } = _param, webglOpts = _object_without_properties_loose(_param, [
|
|
14504
|
-
"root",
|
|
14505
|
-
"canvas",
|
|
14506
|
-
"autoStart",
|
|
14507
|
-
"autoResize",
|
|
14508
|
-
"shadows",
|
|
14509
|
-
"camera",
|
|
14510
|
-
"targetFrameRate",
|
|
14511
|
-
"colorSpace",
|
|
14512
|
-
"toneMapping",
|
|
14513
|
-
"toneMappingExposure",
|
|
14514
|
-
"maxDPR",
|
|
14515
|
-
"path",
|
|
14516
|
-
"resourcePath",
|
|
14517
|
-
"dracoPath",
|
|
14518
|
-
"loader",
|
|
14519
|
-
"tasker"
|
|
14520
|
-
]);
|
|
14414
|
+
constructor({ root, canvas, autoStart = true, autoResize = true, shadows = false, camera = {
|
|
14415
|
+
fov: 45,
|
|
14416
|
+
near: 1,
|
|
14417
|
+
far: 1000,
|
|
14418
|
+
position: new three.Vector3(0, 0, 4)
|
|
14419
|
+
}, targetFrameRate = -1, colorSpace = three.SRGBColorSpace, toneMapping = three.LinearToneMapping, toneMappingExposure = 1, maxDPR = 1.5, path = "", resourcePath = "", dracoPath = "https://www.gstatic.com/draco/v1/decoders/", loader = {}, tasker = {}, ...webglOpts } = {}){
|
|
14521
14420
|
super();
|
|
14522
14421
|
this._dpr = 1;
|
|
14523
14422
|
this._width = 1;
|