@xviewer.js/core 1.0.5-alhpa.1 → 1.0.5-alhpa.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/main.cjs +68 -43
- package/dist/main.cjs.map +1 -1
- package/dist/module.js +68 -43
- package/dist/module.js.map +1 -1
- package/package.json +2 -2
- package/types/DeviceInput.d.ts +6 -1
- package/types/Viewer.d.ts +5 -8
- package/types/components/Environment.d.ts +1 -1
- package/types/components/RenderTexture.d.ts +1 -1
- package/types/materials/ReflectorMaterial.d.ts +3 -0
- package/types/passes/cubeuv/MergeBlurPass.d.ts +2 -2
- package/types/passes/cubeuv/MergeReflectPass.d.ts +1 -1
package/dist/module.js
CHANGED
|
@@ -5,7 +5,7 @@ import { DRACOLoader } from 'three/examples/jsm/loaders/DRACOLoader.js';
|
|
|
5
5
|
import { MeshoptDecoder } from 'three/examples/jsm/libs/meshopt_decoder.module.js';
|
|
6
6
|
import * as THREE from 'three';
|
|
7
7
|
import { EquirectangularReflectionMapping, FileLoader, TextureLoader as TextureLoader$1, SRGBColorSpace, CubeUVReflectionMapping, Mesh, BoxGeometry, SphereGeometry, PlaneGeometry, MathUtils, Vector3, Vector2, LinearInterpolant, Object3D, Plane as Plane$1, Matrix4, Vector4, PerspectiveCamera, WebGLRenderTarget, LinearMipMapLinearFilter, LinearFilter, HalfFloatType, AnimationMixer, Color, OrthographicCamera, MeshDepthMaterial, ShaderMaterial, Euler, Group, REVISION, Box3, Sphere as Sphere$1, Raycaster, Quaternion, Spherical, UniformsUtils, NoBlending, AdditiveBlending, FloatType, UnsignedByteType, LinearSRGBColorSpace, NearestFilter, ClampToEdgeWrapping, WebGLCubeRenderTarget, DataTexture, RGBAFormat, UVMapping, BufferGeometry, Float32BufferAttribute, Scene, WebGLRenderer, LinearToneMapping, PCFSoftShadowMap, LoadingManager, PMREMGenerator, CubeCamera, ShaderLib, ShaderChunk, BufferAttribute, NormalBlending } from 'three';
|
|
8
|
-
import {
|
|
8
|
+
import { HDRLoader as HDRLoader$1 } from 'three/examples/jsm/loaders/HDRLoader.js';
|
|
9
9
|
import { SVGLoader as SVGLoader$1 } from 'three/examples/jsm/loaders/SVGLoader.js';
|
|
10
10
|
import { KTX2Loader as KTX2Loader$1 } from 'three/examples/jsm/loaders/KTX2Loader.js';
|
|
11
11
|
import { HorizontalBlurShader, VerticalBlurShader } from 'three/examples/jsm/Addons.js';
|
|
@@ -271,7 +271,7 @@ class HDRLoader extends Loader {
|
|
|
271
271
|
load({ url, path, resourcePath, manager, texSettings, onLoad, onProgress, onError }) {
|
|
272
272
|
let loader = this._loader;
|
|
273
273
|
if (loader === undefined) {
|
|
274
|
-
loader = this._loader = new
|
|
274
|
+
loader = this._loader = new HDRLoader$1();
|
|
275
275
|
}
|
|
276
276
|
loader.manager = manager;
|
|
277
277
|
loader.setPath(path);
|
|
@@ -2627,9 +2627,15 @@ class DeviceInput extends Component {
|
|
|
2627
2627
|
get pointerPixel() {
|
|
2628
2628
|
return this._pointerPixel;
|
|
2629
2629
|
}
|
|
2630
|
+
get pointerDown() {
|
|
2631
|
+
return this._pointerDown;
|
|
2632
|
+
}
|
|
2630
2633
|
get pointerButton() {
|
|
2631
2634
|
return this._pointerButton;
|
|
2632
2635
|
}
|
|
2636
|
+
get pointerMoving() {
|
|
2637
|
+
return this._pointerMoving;
|
|
2638
|
+
}
|
|
2633
2639
|
get prePointer() {
|
|
2634
2640
|
return this._prePointer;
|
|
2635
2641
|
}
|
|
@@ -2657,6 +2663,9 @@ class DeviceInput extends Component {
|
|
|
2657
2663
|
get keys() {
|
|
2658
2664
|
return this._keys;
|
|
2659
2665
|
}
|
|
2666
|
+
get pressability() {
|
|
2667
|
+
return this._pressability;
|
|
2668
|
+
}
|
|
2660
2669
|
onEnable() {
|
|
2661
2670
|
const dom = this._target;
|
|
2662
2671
|
this._addEventListener(dom, 'contextmenu', (e)=>e.preventDefault());
|
|
@@ -2709,6 +2718,8 @@ class DeviceInput extends Component {
|
|
|
2709
2718
|
this._listeners = [];
|
|
2710
2719
|
}
|
|
2711
2720
|
lastUpdate(dt) {
|
|
2721
|
+
this._pointerDown = false;
|
|
2722
|
+
this._pointerMoving = false;
|
|
2712
2723
|
this._prePointer.copy(this._pointer);
|
|
2713
2724
|
this._prePointerPixel.copy(this._pointerPixel);
|
|
2714
2725
|
for(let i = this._touchCount; i--;){
|
|
@@ -2793,6 +2804,7 @@ class DeviceInput extends Component {
|
|
|
2793
2804
|
}
|
|
2794
2805
|
_onPointerDown(e) {
|
|
2795
2806
|
e = this._remapPointer(e);
|
|
2807
|
+
this._pointerDown = true;
|
|
2796
2808
|
this._pointerButton = e.button;
|
|
2797
2809
|
this._computePointer(e);
|
|
2798
2810
|
this._prePointer.copy(this._pointer);
|
|
@@ -2810,6 +2822,7 @@ class DeviceInput extends Component {
|
|
|
2810
2822
|
_onPointerMove(e) {
|
|
2811
2823
|
e = this._remapPointer(e);
|
|
2812
2824
|
this._computePointer(e);
|
|
2825
|
+
this._pointerMoving = true;
|
|
2813
2826
|
this._pressability.pointerMove(this._pointer, this.viewer.camera);
|
|
2814
2827
|
this.viewer.emit(DeviceInput.POINTER_MOVE, e);
|
|
2815
2828
|
}
|
|
@@ -2877,7 +2890,7 @@ class DeviceInput extends Component {
|
|
|
2877
2890
|
this.viewer.emit(DeviceInput.KEYUP, e);
|
|
2878
2891
|
}
|
|
2879
2892
|
constructor(option){
|
|
2880
|
-
super(), this._listeners = [], this._touches = [], this._touchCount = 0, this._touchStart = false, this._touchMoving = false, this._pointer = new Vector2(), this._pointerPixel = new Vector2(), this._pointerButton = -1, this._prePointer = new Vector2(), this._prePointerPixel = new Vector2(), this._preTouches = [], this._mouseWheel = 0, this._keys = {}, this._pressability = new Pressability();
|
|
2893
|
+
super(), this._listeners = [], this._touches = [], this._touchCount = 0, this._touchStart = false, this._touchMoving = false, this._pointer = new Vector2(), this._pointerPixel = new Vector2(), this._pointerButton = -1, this._pointerDown = false, this._pointerMoving = false, this._prePointer = new Vector2(), this._prePointerPixel = new Vector2(), this._preTouches = [], this._mouseWheel = 0, this._keys = {}, this._pressability = new Pressability();
|
|
2881
2894
|
this._target = option.source;
|
|
2882
2895
|
this._normalizeWheel = option.normalizeWheel || normalizeWheel;
|
|
2883
2896
|
}
|
|
@@ -3914,6 +3927,12 @@ class ReflectorMaterial extends ShaderMaterial {
|
|
|
3914
3927
|
set aoMap(v) {
|
|
3915
3928
|
this.uniforms.aoMap.value = v;
|
|
3916
3929
|
}
|
|
3930
|
+
get aoMapIntensity() {
|
|
3931
|
+
return this.uniforms.aoMapIntensity.value;
|
|
3932
|
+
}
|
|
3933
|
+
set aoMapIntensity(v) {
|
|
3934
|
+
this.uniforms.aoMapIntensity.value = v;
|
|
3935
|
+
}
|
|
3917
3936
|
get lightMap() {
|
|
3918
3937
|
return this.uniforms.lightMap.value;
|
|
3919
3938
|
}
|
|
@@ -3992,6 +4011,9 @@ class ReflectorMaterial extends ShaderMaterial {
|
|
|
3992
4011
|
},
|
|
3993
4012
|
lightMapIntensity: {
|
|
3994
4013
|
value: 1
|
|
4014
|
+
},
|
|
4015
|
+
dfgLUT: {
|
|
4016
|
+
value: null
|
|
3995
4017
|
}
|
|
3996
4018
|
};
|
|
3997
4019
|
Object.defineProperty(this, "opacity", {
|
|
@@ -4038,6 +4060,12 @@ __decorate([
|
|
|
4038
4060
|
__decorate([
|
|
4039
4061
|
property
|
|
4040
4062
|
], ReflectorMaterial.prototype, "aoMap", null);
|
|
4063
|
+
__decorate([
|
|
4064
|
+
property({
|
|
4065
|
+
min: 0,
|
|
4066
|
+
max: 1
|
|
4067
|
+
})
|
|
4068
|
+
], ReflectorMaterial.prototype, "aoMapIntensity", null);
|
|
4041
4069
|
__decorate([
|
|
4042
4070
|
property
|
|
4043
4071
|
], ReflectorMaterial.prototype, "lightMap", null);
|
|
@@ -4731,44 +4759,43 @@ class Viewer extends EventEmitter {
|
|
|
4731
4759
|
};
|
|
4732
4760
|
}
|
|
4733
4761
|
}
|
|
4734
|
-
|
|
4735
|
-
|
|
4736
|
-
|
|
4737
|
-
|
|
4738
|
-
|
|
4739
|
-
if (delta >= interval) {
|
|
4740
|
-
this.loop(this._fixedFrameTime ? interval : this._time - this._lastTime);
|
|
4741
|
-
this._lastTime = this._time;
|
|
4742
|
-
this._lastFrameTime = this._time - delta % interval;
|
|
4762
|
+
animate() {
|
|
4763
|
+
const loop = (dt)=>{
|
|
4764
|
+
if (!this._active) return;
|
|
4765
|
+
if (this._resourceManager.isComplete) {
|
|
4766
|
+
this._taskManager.isComplete ? this._running = true : this._taskManager.update();
|
|
4743
4767
|
}
|
|
4744
|
-
|
|
4745
|
-
|
|
4746
|
-
|
|
4747
|
-
|
|
4748
|
-
|
|
4749
|
-
loop(dt) {
|
|
4750
|
-
if (this._resourceManager.isComplete) {
|
|
4751
|
-
this._taskManager.update();
|
|
4752
|
-
if (this._taskManager.isComplete) {
|
|
4753
|
-
this._running = true;
|
|
4768
|
+
if (this._running) {
|
|
4769
|
+
dt = Math.min(dt, 0.067);
|
|
4770
|
+
this._renderer.info.reset();
|
|
4771
|
+
this._componentManager.update(dt);
|
|
4772
|
+
this._componentManager.render(dt);
|
|
4754
4773
|
}
|
|
4755
|
-
}
|
|
4756
|
-
|
|
4757
|
-
|
|
4758
|
-
this.
|
|
4759
|
-
|
|
4760
|
-
|
|
4761
|
-
|
|
4774
|
+
};
|
|
4775
|
+
const frame = (time)=>{
|
|
4776
|
+
this._time = time * 0.001;
|
|
4777
|
+
if (this._targetFrameRate > -1) {
|
|
4778
|
+
const interval = 1 / this._targetFrameRate;
|
|
4779
|
+
const delta = this._time - this._lastFrameTime;
|
|
4780
|
+
if (delta >= interval) {
|
|
4781
|
+
loop(this._fixedFrameTime ? interval : this._time - this._lastTime);
|
|
4782
|
+
this._lastTime = this._time;
|
|
4783
|
+
this._lastFrameTime = this._time - delta % interval;
|
|
4784
|
+
}
|
|
4785
|
+
} else {
|
|
4786
|
+
loop(this._time - this._lastTime);
|
|
4787
|
+
this._lastTime = this._time;
|
|
4788
|
+
}
|
|
4789
|
+
};
|
|
4790
|
+
this._renderer.setAnimationLoop(frame);
|
|
4762
4791
|
}
|
|
4763
4792
|
start() {
|
|
4764
|
-
if (this._active
|
|
4793
|
+
if (this._active === false) {
|
|
4765
4794
|
this._active = true;
|
|
4766
|
-
|
|
4767
|
-
|
|
4768
|
-
|
|
4769
|
-
|
|
4770
|
-
};
|
|
4771
|
-
this._renderer.setAnimationLoop(frameCallback);
|
|
4795
|
+
requestAnimationFrame(()=>{
|
|
4796
|
+
this.rotate();
|
|
4797
|
+
this.resize();
|
|
4798
|
+
});
|
|
4772
4799
|
}
|
|
4773
4800
|
return this;
|
|
4774
4801
|
}
|
|
@@ -4908,7 +4935,7 @@ class Viewer extends EventEmitter {
|
|
|
4908
4935
|
if (parent === undefined) {
|
|
4909
4936
|
parent = mount ? this._mount : this._scene;
|
|
4910
4937
|
}
|
|
4911
|
-
if (parent && !node.parent) {
|
|
4938
|
+
if (parent !== node && !node.parent) {
|
|
4912
4939
|
parent.add(node);
|
|
4913
4940
|
}
|
|
4914
4941
|
if (component) {
|
|
@@ -5128,7 +5155,7 @@ class Viewer extends EventEmitter {
|
|
|
5128
5155
|
width: 1,
|
|
5129
5156
|
height: 1,
|
|
5130
5157
|
factor: 1
|
|
5131
|
-
}, this._active = false, this.
|
|
5158
|
+
}, this._active = false, this._running = false, this._rootRotated = false, this._time = 0, this._lastTime = 0, this._lastFrameTime = 0, this._targetFrameRate = -1, this._fixedFrameTime = false, this._windowSize = ()=>[
|
|
5132
5159
|
window.innerWidth,
|
|
5133
5160
|
window.innerHeight
|
|
5134
5161
|
], this._orientation = Orientation.AUTO;
|
|
@@ -5186,11 +5213,9 @@ class Viewer extends EventEmitter {
|
|
|
5186
5213
|
this.addLoader(BINLoader);
|
|
5187
5214
|
this.addLoader(SVGLoader);
|
|
5188
5215
|
this.addLoader(KTX2Loader);
|
|
5189
|
-
|
|
5190
|
-
|
|
5191
|
-
|
|
5192
|
-
this.start();
|
|
5193
|
-
});
|
|
5216
|
+
this.rotate();
|
|
5217
|
+
this.resize();
|
|
5218
|
+
this.animate();
|
|
5194
5219
|
}
|
|
5195
5220
|
}
|
|
5196
5221
|
Viewer.instanceCount = 0;
|