@xviewer.js/core 1.0.0-alpha.5 → 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 +29 -124
- package/dist/main.js.map +1 -1
- package/dist/module.js +30 -125
- package/dist/module.js.map +1 -1
- package/package.json +1 -1
package/dist/module.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Mesh, TrianglesDrawMode, TriangleFanDrawMode, TriangleStripDrawMode, Loader, LoaderUtils, FileLoader, Color, LinearSRGBColorSpace, SpotLight, PointLight, DirectionalLight, MeshBasicMaterial, SRGBColorSpace, MeshPhysicalMaterial, Vector2, Matrix4, Vector3, Quaternion, InstancedMesh, InstancedBufferAttribute, Object3D, TextureLoader, ImageBitmapLoader, BufferAttribute, InterleavedBuffer, InterleavedBufferAttribute, LinearFilter, LinearMipmapLinearFilter, RepeatWrapping, PointsMaterial, Material, LineBasicMaterial, MeshStandardMaterial, DoubleSide, PropertyBinding, BufferGeometry, SkinnedMesh, LineSegments, Line, LineLoop, Points, Group as Group$1, PerspectiveCamera, MathUtils, OrthographicCamera, Skeleton, AnimationClip, Bone, InterpolateLinear, ColorManagement, NearestFilter, NearestMipmapNearestFilter, LinearMipmapNearestFilter, NearestMipmapLinearFilter, ClampToEdgeWrapping, MirroredRepeatWrapping, InterpolateDiscrete, FrontSide, Texture, VectorKeyframeTrack, NumberKeyframeTrack, QuaternionKeyframeTrack, Box3, Sphere as Sphere$1, Interpolant, Vector4, Curve, MeshPhongMaterial, MeshLambertMaterial, EquirectangularReflectionMapping, AmbientLight, Float32BufferAttribute, Uint16BufferAttribute, Matrix3, ShapeUtils, Euler, DataTextureLoader, HalfFloatType, FloatType, DataUtils, Raycaster, Spherical, BoxGeometry, SphereGeometry, PlaneGeometry, UnsignedByteType, WebGLRenderTarget, LinearMipMapLinearFilter, WebGLCubeRenderTarget, DataTexture, RGBAFormat, UVMapping, Scene,
|
|
1
|
+
import { Mesh, TrianglesDrawMode, TriangleFanDrawMode, TriangleStripDrawMode, Loader, LoaderUtils, FileLoader, Color, LinearSRGBColorSpace, SpotLight, PointLight, DirectionalLight, MeshBasicMaterial, SRGBColorSpace, MeshPhysicalMaterial, Vector2, Matrix4, Vector3, Quaternion, InstancedMesh, InstancedBufferAttribute, Object3D, TextureLoader, ImageBitmapLoader, BufferAttribute, InterleavedBuffer, InterleavedBufferAttribute, LinearFilter, LinearMipmapLinearFilter, RepeatWrapping, PointsMaterial, Material, LineBasicMaterial, MeshStandardMaterial, DoubleSide, PropertyBinding, BufferGeometry, SkinnedMesh, LineSegments, Line, LineLoop, Points, Group as Group$1, PerspectiveCamera, MathUtils, OrthographicCamera, Skeleton, AnimationClip, Bone, InterpolateLinear, ColorManagement, NearestFilter, NearestMipmapNearestFilter, LinearMipmapNearestFilter, NearestMipmapLinearFilter, ClampToEdgeWrapping, MirroredRepeatWrapping, InterpolateDiscrete, FrontSide, Texture, VectorKeyframeTrack, NumberKeyframeTrack, QuaternionKeyframeTrack, Box3, Sphere as Sphere$1, Interpolant, Vector4, Curve, MeshPhongMaterial, MeshLambertMaterial, EquirectangularReflectionMapping, AmbientLight, Float32BufferAttribute, Uint16BufferAttribute, Matrix3, ShapeUtils, Euler, DataTextureLoader, HalfFloatType, FloatType, DataUtils, Raycaster, Spherical, BoxGeometry, SphereGeometry, PlaneGeometry, UnsignedByteType, WebGLRenderTarget, LinearMipMapLinearFilter, WebGLCubeRenderTarget, DataTexture, RGBAFormat, UVMapping, Scene, WebGLRenderer, PCFSoftShadowMap, LoadingManager, LinearToneMapping } from 'three';
|
|
2
2
|
|
|
3
3
|
class EventEmitter {
|
|
4
4
|
_removeEvent(list, index, name) {
|
|
@@ -1063,22 +1063,6 @@ class aLoader {
|
|
|
1063
1063
|
}
|
|
1064
1064
|
}
|
|
1065
1065
|
|
|
1066
|
-
function _object_without_properties_loose(source, excluded) {
|
|
1067
|
-
if (source == null) return {};
|
|
1068
|
-
|
|
1069
|
-
var target = {};
|
|
1070
|
-
var sourceKeys = Object.keys(source);
|
|
1071
|
-
var key, i;
|
|
1072
|
-
|
|
1073
|
-
for (i = 0; i < sourceKeys.length; i++) {
|
|
1074
|
-
key = sourceKeys[i];
|
|
1075
|
-
if (excluded.indexOf(key) >= 0) continue;
|
|
1076
|
-
target[key] = source[key];
|
|
1077
|
-
}
|
|
1078
|
-
|
|
1079
|
-
return target;
|
|
1080
|
-
}
|
|
1081
|
-
|
|
1082
1066
|
class ResourceManager {
|
|
1083
1067
|
static extension(path) {
|
|
1084
1068
|
let str = path.split(".");
|
|
@@ -1148,12 +1132,7 @@ class ResourceManager {
|
|
|
1148
1132
|
destroy() {
|
|
1149
1133
|
this._caches.clear();
|
|
1150
1134
|
}
|
|
1151
|
-
loadAsset(
|
|
1152
|
-
var { url, ext, onProgress } = _param, props = _object_without_properties_loose(_param, [
|
|
1153
|
-
"url",
|
|
1154
|
-
"ext",
|
|
1155
|
-
"onProgress"
|
|
1156
|
-
]);
|
|
1135
|
+
loadAsset({ url, ext, onProgress, ...props }) {
|
|
1157
1136
|
return new Promise((resolve, reject)=>{
|
|
1158
1137
|
const info = ResourceManager._parseURL(url);
|
|
1159
1138
|
const texSettings = ResourceManager._splitTextureSettings(props);
|
|
@@ -13201,11 +13180,10 @@ const Vector3_ZERO = new Vector3();
|
|
|
13201
13180
|
|
|
13202
13181
|
const { clamp, degToRad } = MathUtils;
|
|
13203
13182
|
const { abs, tan } = Math;
|
|
13204
|
-
|
|
13205
|
-
|
|
13206
|
-
|
|
13207
|
-
|
|
13208
|
-
})(VCamFreeLookMode || (VCamFreeLookMode = {}));
|
|
13183
|
+
const VCamFreeLookMode = {
|
|
13184
|
+
FREE: 0,
|
|
13185
|
+
TRANSLATE: 1
|
|
13186
|
+
};
|
|
13209
13187
|
class FreelookVirtualCamera extends VirtualCamera {
|
|
13210
13188
|
onEnable() {
|
|
13211
13189
|
this.viewer.on(DeviceInput.POINTER_DOWN, this._onPointerDown, this);
|
|
@@ -13344,7 +13322,7 @@ class FreelookVirtualCamera extends VirtualCamera {
|
|
|
13344
13322
|
const { __posDelta, __posOffset, __worldPos, __quat, __spherical, __xAxis, __yAxis } = FreelookVirtualCamera;
|
|
13345
13323
|
__worldPos.copy(this.lookAt.position).add(this.trackedObjectOffset);
|
|
13346
13324
|
switch(this.mode){
|
|
13347
|
-
case
|
|
13325
|
+
case VCamFreeLookMode.FREE:
|
|
13348
13326
|
if (abs(this._rotateDelta.x) + abs(this._rotateDelta.y) + abs(this._distanceDelta) > 0.001) {
|
|
13349
13327
|
const { __posDelta, __posOffset, __worldPos } = FreelookVirtualCamera;
|
|
13350
13328
|
__quat.setFromUnitVectors(this.node.up, Object3D.DEFAULT_UP);
|
|
@@ -13365,7 +13343,7 @@ class FreelookVirtualCamera extends VirtualCamera {
|
|
|
13365
13343
|
this.node.position.copy(__posDelta.add(__worldPos));
|
|
13366
13344
|
}
|
|
13367
13345
|
break;
|
|
13368
|
-
case
|
|
13346
|
+
case VCamFreeLookMode.TRANSLATE:
|
|
13369
13347
|
if (abs(this._distanceDelta) > 0.001) {
|
|
13370
13348
|
__posDelta.copy(this.node.position).sub(this.lookAt.position);
|
|
13371
13349
|
let dampFactor = quarticDamp(1, 0, this.rotateSmoothing, dt);
|
|
@@ -13409,7 +13387,7 @@ class FreelookVirtualCamera extends VirtualCamera {
|
|
|
13409
13387
|
this._preLoc1 = new Vector2();
|
|
13410
13388
|
this._rotateDelta = new Vector2();
|
|
13411
13389
|
this._panDelta = new Vector2();
|
|
13412
|
-
this.mode =
|
|
13390
|
+
this.mode = VCamFreeLookMode.FREE;
|
|
13413
13391
|
this.forbidX = false;
|
|
13414
13392
|
this.forbidY = false;
|
|
13415
13393
|
this.forbidZ = false;
|
|
@@ -13465,10 +13443,7 @@ FreelookVirtualCamera.__quat = new Quaternion();
|
|
|
13465
13443
|
FreelookVirtualCamera.__spherical = new Spherical();
|
|
13466
13444
|
__decorate([
|
|
13467
13445
|
property({
|
|
13468
|
-
value:
|
|
13469
|
-
FREE: 0,
|
|
13470
|
-
TRANSLATE: 1
|
|
13471
|
-
}
|
|
13446
|
+
value: VCamFreeLookMode
|
|
13472
13447
|
})
|
|
13473
13448
|
], FreelookVirtualCamera.prototype, "mode", void 0);
|
|
13474
13449
|
__decorate([
|
|
@@ -13520,37 +13495,6 @@ class Plane extends Mesh {
|
|
|
13520
13495
|
}
|
|
13521
13496
|
}
|
|
13522
13497
|
|
|
13523
|
-
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
13524
|
-
try {
|
|
13525
|
-
var info = gen[key](arg);
|
|
13526
|
-
var value = info.value;
|
|
13527
|
-
} catch (error) {
|
|
13528
|
-
reject(error);
|
|
13529
|
-
return;
|
|
13530
|
-
}
|
|
13531
|
-
if (info.done) resolve(value);
|
|
13532
|
-
else Promise.resolve(value).then(_next, _throw);
|
|
13533
|
-
}
|
|
13534
|
-
function _async_to_generator(fn) {
|
|
13535
|
-
return function() {
|
|
13536
|
-
var self = this, args = arguments;
|
|
13537
|
-
|
|
13538
|
-
return new Promise(function(resolve, reject) {
|
|
13539
|
-
var gen = fn.apply(self, args);
|
|
13540
|
-
|
|
13541
|
-
function _next(value) {
|
|
13542
|
-
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
13543
|
-
}
|
|
13544
|
-
|
|
13545
|
-
function _throw(err) {
|
|
13546
|
-
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
13547
|
-
}
|
|
13548
|
-
|
|
13549
|
-
_next(undefined);
|
|
13550
|
-
});
|
|
13551
|
-
};
|
|
13552
|
-
}
|
|
13553
|
-
|
|
13554
13498
|
class Caller {
|
|
13555
13499
|
get pause() {
|
|
13556
13500
|
return this._pause;
|
|
@@ -14282,30 +14226,20 @@ class Viewer extends EventEmitter {
|
|
|
14282
14226
|
loadAsset(props) {
|
|
14283
14227
|
return this._resourceManager.loadAsset(props);
|
|
14284
14228
|
}
|
|
14285
|
-
load(
|
|
14286
|
-
|
|
14287
|
-
|
|
14288
|
-
|
|
14289
|
-
|
|
14290
|
-
|
|
14291
|
-
|
|
14292
|
-
|
|
14293
|
-
|
|
14294
|
-
|
|
14295
|
-
const node = yield _this.loadAsset({
|
|
14296
|
-
url,
|
|
14297
|
-
ext,
|
|
14298
|
-
onProgress
|
|
14229
|
+
async load({ url, ext, onProgress, castShadow = false, receiveShadow = false, ...props }) {
|
|
14230
|
+
const node = await this.loadAsset({
|
|
14231
|
+
url,
|
|
14232
|
+
ext,
|
|
14233
|
+
onProgress
|
|
14234
|
+
});
|
|
14235
|
+
if (castShadow || receiveShadow) {
|
|
14236
|
+
node.userData.meshData.meshes.forEach((v)=>{
|
|
14237
|
+
v.castShadow = castShadow;
|
|
14238
|
+
v.receiveShadow = receiveShadow;
|
|
14299
14239
|
});
|
|
14300
|
-
|
|
14301
|
-
|
|
14302
|
-
|
|
14303
|
-
v.receiveShadow = receiveShadow;
|
|
14304
|
-
});
|
|
14305
|
-
}
|
|
14306
|
-
_this.addNode(node, props);
|
|
14307
|
-
return node;
|
|
14308
|
-
})();
|
|
14240
|
+
}
|
|
14241
|
+
this.addNode(node, props);
|
|
14242
|
+
return node;
|
|
14309
14243
|
}
|
|
14310
14244
|
tween(target) {
|
|
14311
14245
|
return this._tweenManager.tween(target);
|
|
@@ -14354,18 +14288,7 @@ class Viewer extends EventEmitter {
|
|
|
14354
14288
|
removeComponent(node, component) {
|
|
14355
14289
|
return this._componentManager.removeComponent(node, component);
|
|
14356
14290
|
}
|
|
14357
|
-
addNode(object,
|
|
14358
|
-
var { args, debug, scale, position, rotation, shadowArgs, makeDefault, component, parent = this._scene } = _param, props = _object_without_properties_loose(_param, [
|
|
14359
|
-
"args",
|
|
14360
|
-
"debug",
|
|
14361
|
-
"scale",
|
|
14362
|
-
"position",
|
|
14363
|
-
"rotation",
|
|
14364
|
-
"shadowArgs",
|
|
14365
|
-
"makeDefault",
|
|
14366
|
-
"component",
|
|
14367
|
-
"parent"
|
|
14368
|
-
]);
|
|
14291
|
+
addNode(object, { args, debug, scale, position, rotation, shadowArgs, makeDefault, component, parent = this._scene, ...props } = {}) {
|
|
14369
14292
|
let node = null;
|
|
14370
14293
|
let ins = Viewer._getClassInstance(object, args);
|
|
14371
14294
|
if (ins.isObject3D) {
|
|
@@ -14486,30 +14409,12 @@ class Viewer extends EventEmitter {
|
|
|
14486
14409
|
Viewer.CompileObject3D(this._renderer, this._scene, this._camera, this._scene);
|
|
14487
14410
|
}
|
|
14488
14411
|
}
|
|
14489
|
-
constructor(
|
|
14490
|
-
|
|
14491
|
-
|
|
14492
|
-
|
|
14493
|
-
|
|
14494
|
-
|
|
14495
|
-
}, targetFrameRate = -1, colorSpace = SRGBColorSpace, toneMapping = 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, [
|
|
14496
|
-
"root",
|
|
14497
|
-
"canvas",
|
|
14498
|
-
"autoStart",
|
|
14499
|
-
"autoResize",
|
|
14500
|
-
"shadows",
|
|
14501
|
-
"camera",
|
|
14502
|
-
"targetFrameRate",
|
|
14503
|
-
"colorSpace",
|
|
14504
|
-
"toneMapping",
|
|
14505
|
-
"toneMappingExposure",
|
|
14506
|
-
"maxDPR",
|
|
14507
|
-
"path",
|
|
14508
|
-
"resourcePath",
|
|
14509
|
-
"dracoPath",
|
|
14510
|
-
"loader",
|
|
14511
|
-
"tasker"
|
|
14512
|
-
]);
|
|
14412
|
+
constructor({ root, canvas, autoStart = true, autoResize = true, shadows = false, camera = {
|
|
14413
|
+
fov: 45,
|
|
14414
|
+
near: 1,
|
|
14415
|
+
far: 1000,
|
|
14416
|
+
position: new Vector3(0, 0, 4)
|
|
14417
|
+
}, targetFrameRate = -1, colorSpace = SRGBColorSpace, toneMapping = LinearToneMapping, toneMappingExposure = 1, maxDPR = 1.5, path = "", resourcePath = "", dracoPath = "https://www.gstatic.com/draco/v1/decoders/", loader = {}, tasker = {}, ...webglOpts } = {}){
|
|
14513
14418
|
super();
|
|
14514
14419
|
this._dpr = 1;
|
|
14515
14420
|
this._width = 1;
|