@xviewer.js/core 1.0.0-alpha.20 → 1.0.0-alpha.21
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 +600 -7
- package/dist/main.js.map +1 -1
- package/dist/module.js +576 -9
- package/dist/module.js.map +1 -1
- package/package.json +1 -1
- package/types/Viewer.d.ts +3 -2
- package/types/index.d.ts +2 -0
- package/types/math/Constant.d.ts +8 -1
- package/types/math/Perlin.d.ts +12 -0
- package/types/math/index.d.ts +5 -0
- package/types/tween/TweenChain.d.ts +12 -4
package/dist/module.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Mesh, EquirectangularReflectionMapping, FileLoader, TextureLoader, SRGBColorSpace, MathUtils, Vector3, Quaternion, Raycaster, Vector2, Spherical, Object3D, BoxGeometry, SphereGeometry, PlaneGeometry, HalfFloatType, FloatType, UnsignedByteType, OrthographicCamera, BufferGeometry, Float32BufferAttribute, WebGLRenderTarget, ClampToEdgeWrapping, NearestFilter, LinearFilter, LinearMipMapLinearFilter, WebGLCubeRenderTarget, DataTexture, RGBAFormat, UVMapping, Scene, LinearToneMapping, PerspectiveCamera, WebGLRenderer, PCFSoftShadowMap, LoadingManager } from 'three';
|
|
1
|
+
import { Mesh, EquirectangularReflectionMapping, FileLoader, TextureLoader, SRGBColorSpace, MathUtils, Vector3, Quaternion, Raycaster, Vector2, LinearInterpolant, Spherical, Object3D, BoxGeometry, SphereGeometry, PlaneGeometry, HalfFloatType, FloatType, UnsignedByteType, OrthographicCamera, BufferGeometry, Float32BufferAttribute, WebGLRenderTarget, ClampToEdgeWrapping, NearestFilter, LinearFilter, LinearMipMapLinearFilter, WebGLCubeRenderTarget, DataTexture, RGBAFormat, UVMapping, Scene, LinearToneMapping, PerspectiveCamera, WebGLRenderer, PCFSoftShadowMap, LoadingManager } from 'three';
|
|
2
2
|
import { EXRLoader } from 'three/examples/jsm/loaders/EXRLoader.js';
|
|
3
3
|
import { FBXLoader } from 'three/examples/jsm/loaders/FBXLoader.js';
|
|
4
4
|
import { GLTFLoader } from 'three/examples/jsm/loaders/GLTFLoader.js';
|
|
@@ -1345,7 +1345,7 @@ class Component extends ObjectInstance {
|
|
|
1345
1345
|
}
|
|
1346
1346
|
}
|
|
1347
1347
|
|
|
1348
|
-
const { clamp: clamp$
|
|
1348
|
+
const { clamp: clamp$4, lerp: lerp$1 } = MathUtils;
|
|
1349
1349
|
class CinestationBrain extends Component {
|
|
1350
1350
|
get vcam() {
|
|
1351
1351
|
return this._vcam;
|
|
@@ -1359,7 +1359,7 @@ class CinestationBrain extends Component {
|
|
|
1359
1359
|
this._vcams.forEach((v)=>v.enabled = v === vcam);
|
|
1360
1360
|
if (this._lerpTime < this.brainBlend.time) {
|
|
1361
1361
|
this._lerpTime += dt;
|
|
1362
|
-
let t = clamp$
|
|
1362
|
+
let t = clamp$4(this._lerpTime / this.brainBlend.time, 0, 1);
|
|
1363
1363
|
this._lerpToMainCamera(vcam, this.brainBlend.style(t));
|
|
1364
1364
|
} else {
|
|
1365
1365
|
this._lerpToMainCamera(vcam, 1);
|
|
@@ -1395,9 +1395,9 @@ class CinestationBrain extends Component {
|
|
|
1395
1395
|
const isChanged = isLensChanged || isTransformChanged;
|
|
1396
1396
|
from.position.lerp(finalPosition, t);
|
|
1397
1397
|
from.quaternion.slerp(finalRotation, t);
|
|
1398
|
-
from.fov = lerp(from.fov, fov, t);
|
|
1399
|
-
from.near = lerp(from.near, near, t);
|
|
1400
|
-
from.far = lerp(from.far, far, t);
|
|
1398
|
+
from.fov = lerp$1(from.fov, fov, t);
|
|
1399
|
+
from.near = lerp$1(from.near, near, t);
|
|
1400
|
+
from.far = lerp$1(from.far, far, t);
|
|
1401
1401
|
if (isLensChanged) {
|
|
1402
1402
|
from.updateProjectionMatrix();
|
|
1403
1403
|
}
|
|
@@ -1998,15 +1998,579 @@ SystemInfo.cpuCoreCount = navigator.hardwareConcurrency || 1;
|
|
|
1998
1998
|
SystemInfo.baseUrl = document.location.origin;
|
|
1999
1999
|
SystemInfo.isIFrame = window.self !== window.top;
|
|
2000
2000
|
|
|
2001
|
-
const {
|
|
2001
|
+
const { clamp: clamp$3 } = MathUtils;
|
|
2002
|
+
const { min, max: max$1, exp } = Math;
|
|
2003
|
+
const kNegligibleResidual = 0.01;
|
|
2004
|
+
const kLogNegligibleResidual = Math.log(kNegligibleResidual) // -4.605170186;
|
|
2005
|
+
;
|
|
2006
|
+
function exponentialDamp(current, target, dampTime, deltaTime) {
|
|
2007
|
+
let k = -kLogNegligibleResidual / dampTime;
|
|
2008
|
+
return current + (target - current) * (1 - exp(-k * deltaTime));
|
|
2009
|
+
}
|
|
2002
2010
|
// cuve like exponentialDecay but cost less
|
|
2003
2011
|
function quarticDamp(current, target, dampTime, deltaTime) {
|
|
2004
2012
|
let t = 1 - min(deltaTime, dampTime) / dampTime;
|
|
2005
2013
|
let tt = t * t;
|
|
2006
2014
|
return current + (target - current) * (1 - tt * tt);
|
|
2007
2015
|
}
|
|
2016
|
+
function smoothDamp(state, current, target, smoothTime, maxSpeed, deltaTime) {
|
|
2017
|
+
if (state._velocity === undefined) {
|
|
2018
|
+
state._velocity = 0;
|
|
2019
|
+
}
|
|
2020
|
+
smoothTime = max$1(0.0001, smoothTime);
|
|
2021
|
+
let num = 2 / smoothTime;
|
|
2022
|
+
let num2 = num * deltaTime;
|
|
2023
|
+
let num3 = 1 / (1 + num2 + 0.48 * num2 * num2 + 0.235 * num2 * num2 * num2);
|
|
2024
|
+
let num4 = current - target;
|
|
2025
|
+
let num5 = target;
|
|
2026
|
+
let num6 = maxSpeed * smoothTime;
|
|
2027
|
+
num4 = clamp$3(num4, -num6, num6);
|
|
2028
|
+
target = current - num4;
|
|
2029
|
+
let num7 = (state._velocity + num * num4) * deltaTime;
|
|
2030
|
+
state._velocity = (state._velocity - num * num7) * num3;
|
|
2031
|
+
let num8 = target + (num4 + num7) * num3;
|
|
2032
|
+
if (num5 - current > 0 == num8 > num5) {
|
|
2033
|
+
num8 = num5;
|
|
2034
|
+
state._velocity = (num8 - num5) / deltaTime;
|
|
2035
|
+
}
|
|
2036
|
+
return num8;
|
|
2037
|
+
}
|
|
2038
|
+
function Quat_exponentialDamp(current, target, dampTime, deltaTime, out = current) {
|
|
2039
|
+
return out.copy(current).slerp(target, exponentialDamp(0, 1, dampTime, deltaTime));
|
|
2040
|
+
}
|
|
2041
|
+
function Quat_quarticDamp(current, target, dampTime, deltaTime, out = current) {
|
|
2042
|
+
return out.copy(current).slerp(target, quarticDamp(0, 1, dampTime, deltaTime));
|
|
2043
|
+
}
|
|
2044
|
+
function Quat_smoothDamp(current, target, dampTime, deltaTime, out = current) {
|
|
2045
|
+
return out.copy(current).slerp(target, smoothDamp(out, 0, 1, dampTime, Infinity, deltaTime));
|
|
2046
|
+
}
|
|
2047
|
+
function Vec3_smoothDamp(current, target, dampTime, deltaTime, out = current) {
|
|
2048
|
+
return out.copy(current).lerp(target, smoothDamp(out, 0, 1, dampTime, Infinity, deltaTime));
|
|
2049
|
+
}
|
|
2050
|
+
|
|
2051
|
+
const Vector3_UNIT_X = Object.freeze(new Vector3(1, 0, 0));
|
|
2052
|
+
const Vector3_UNIT_Y = Object.freeze(new Vector3(0, 1, 0));
|
|
2053
|
+
const Vector3_UNIT_Z = Object.freeze(new Vector3(0, 0, 1));
|
|
2054
|
+
const Vector3_RIGHT = Object.freeze(new Vector3(1, 0, 0));
|
|
2055
|
+
const Vector3_UP = Object.freeze(new Vector3(0, 1, 0));
|
|
2056
|
+
const Vector3_ZERO = Object.freeze(new Vector3(0, 0, 0));
|
|
2057
|
+
const Vector3_ONE = Object.freeze(new Vector3(1, 1, 1));
|
|
2058
|
+
const Vector3_NEG_ONE = Object.freeze(new Vector3(-1, -1, -1));
|
|
2059
|
+
|
|
2060
|
+
const { clamp: clamp$2 } = MathUtils;
|
|
2061
|
+
const { max, abs: abs$1, acos } = Math;
|
|
2062
|
+
const EPSILON = 1.e-6;
|
|
2063
|
+
const __delta = new Vector3();
|
|
2064
|
+
function VInterpTo(current, target, deltaTime, speed, out = current) {
|
|
2065
|
+
if (speed <= 0) {
|
|
2066
|
+
return out.copy(target);
|
|
2067
|
+
}
|
|
2068
|
+
let dist = __delta.copy(target).sub(current);
|
|
2069
|
+
if (dist.lengthSq() < EPSILON) {
|
|
2070
|
+
return out.copy(target);
|
|
2071
|
+
}
|
|
2072
|
+
return out.copy(current).add(dist.multiplyScalar(clamp$2(deltaTime * speed, 0, 1)));
|
|
2073
|
+
}
|
|
2074
|
+
function VInterpConstantTo(current, target, deltaTime, speed, out = current) {
|
|
2075
|
+
let delta = __delta.copy(target).sub(current);
|
|
2076
|
+
let deltaM = delta.length();
|
|
2077
|
+
let maxStep = speed * deltaTime;
|
|
2078
|
+
if (deltaM > maxStep) {
|
|
2079
|
+
if (maxStep > 0) {
|
|
2080
|
+
let deltaN = delta.multiplyScalar(1 / deltaM);
|
|
2081
|
+
return out.copy(current).add(deltaN);
|
|
2082
|
+
} else {
|
|
2083
|
+
return out.copy(current);
|
|
2084
|
+
}
|
|
2085
|
+
}
|
|
2086
|
+
return out.copy(target);
|
|
2087
|
+
}
|
|
2088
|
+
function Quat_Equals(a, b, epsilon = EPSILON) {
|
|
2089
|
+
return abs$1(a.x - b.x) <= epsilon * max(1., abs$1(a.x), abs$1(b.x)) && abs$1(a.y - b.y) <= epsilon * max(1., abs$1(a.y), abs$1(b.y)) && abs$1(a.z - b.z) <= epsilon * max(1., abs$1(a.z), abs$1(b.z)) && abs$1(a.w - b.w) <= epsilon * max(1., abs$1(a.w), abs$1(b.w));
|
|
2090
|
+
}
|
|
2091
|
+
function Quat_AngularDistance(a, b) {
|
|
2092
|
+
let innerProd = a.x * b.x + a.y * b.y + a.z * b.z + a.w * b.w;
|
|
2093
|
+
return acos(2 * innerProd * innerProd - 1);
|
|
2094
|
+
}
|
|
2095
|
+
function QInterpTo(current, target, deltaTime, speed) {
|
|
2096
|
+
if (speed <= 0) {
|
|
2097
|
+
return target;
|
|
2098
|
+
}
|
|
2099
|
+
if (Quat_Equals(current, target)) {
|
|
2100
|
+
return target;
|
|
2101
|
+
}
|
|
2102
|
+
return current.slerp(target, clamp$2(speed * deltaTime, 0, 1));
|
|
2103
|
+
}
|
|
2104
|
+
function QInterpConstantTo(current, target, deltaTime, speed, out = current) {
|
|
2105
|
+
if (speed <= 0) {
|
|
2106
|
+
return out.copy(target);
|
|
2107
|
+
}
|
|
2108
|
+
if (Quat_Equals(current, target)) {
|
|
2109
|
+
return out.copy(target);
|
|
2110
|
+
}
|
|
2111
|
+
let deltaSpeed = clamp$2(speed * deltaTime, 0, 1);
|
|
2112
|
+
let angularDist = max(Quat_AngularDistance(current, target), EPSILON);
|
|
2113
|
+
return out.copy(current).slerp(target, clamp$2(deltaSpeed / angularDist, 0, 1));
|
|
2114
|
+
}
|
|
2115
|
+
//非线性
|
|
2116
|
+
function FInterpTo(current, target, deltaTime, speed) {
|
|
2117
|
+
if (speed <= 0) {
|
|
2118
|
+
return target;
|
|
2119
|
+
}
|
|
2120
|
+
let dist = target - current;
|
|
2121
|
+
if (abs$1(dist) < EPSILON) {
|
|
2122
|
+
return target;
|
|
2123
|
+
}
|
|
2124
|
+
return current + dist * clamp$2(speed * deltaTime, 0, 1);
|
|
2125
|
+
}
|
|
2126
|
+
//线性插值
|
|
2127
|
+
function FInterpConstantTo(current, target, deltaTime, speed) {
|
|
2128
|
+
let dist = target - current;
|
|
2129
|
+
if (abs$1(dist) < EPSILON) {
|
|
2130
|
+
return target;
|
|
2131
|
+
}
|
|
2132
|
+
let step = speed * deltaTime;
|
|
2133
|
+
return current + clamp$2(dist, -step, step);
|
|
2134
|
+
}
|
|
2135
|
+
|
|
2136
|
+
const { lerp, clamp: clamp$1 } = MathUtils;
|
|
2137
|
+
function catmullRom(t, p0, p1, p2, p3) {
|
|
2138
|
+
const v0 = (p2 - p0) * 0.5;
|
|
2139
|
+
const v1 = (p3 - p1) * 0.5;
|
|
2140
|
+
const t2 = t * t;
|
|
2141
|
+
const t3 = t * t2;
|
|
2142
|
+
return (2 * p1 - 2 * p2 + v0 + v1) * t3 + (-3 * p1 + 3 * p2 - 2 * v0 - v1) * t2 + v0 * t + p1;
|
|
2143
|
+
}
|
|
2144
|
+
class CurvePoint {
|
|
2145
|
+
set(x, y) {
|
|
2146
|
+
this.x = x;
|
|
2147
|
+
this.y = y;
|
|
2148
|
+
return this;
|
|
2149
|
+
}
|
|
2150
|
+
lerp(p, t, out = this) {
|
|
2151
|
+
out.x = lerp(this.x, p.x, t);
|
|
2152
|
+
out.y = lerp(this.y, p.y, t);
|
|
2153
|
+
return out;
|
|
2154
|
+
}
|
|
2155
|
+
constructor(x = 0, y = 0, mode = 0){
|
|
2156
|
+
this.x = x;
|
|
2157
|
+
this.y = y;
|
|
2158
|
+
this.mode = mode;
|
|
2159
|
+
}
|
|
2160
|
+
}
|
|
2161
|
+
class AnimationCurve {
|
|
2162
|
+
_getInterpolant(samples) {
|
|
2163
|
+
if (this._samples !== samples) {
|
|
2164
|
+
this._samples = samples;
|
|
2165
|
+
this._interpolant = new LinearInterpolant(new Float32Array(samples), new Float32Array(samples), 1, new Float32Array(samples));
|
|
2166
|
+
}
|
|
2167
|
+
return this._interpolant;
|
|
2168
|
+
}
|
|
2169
|
+
createCurvePoint(x, y, mode) {
|
|
2170
|
+
return new CurvePoint(x, y, mode);
|
|
2171
|
+
}
|
|
2172
|
+
resample(samples = 100) {
|
|
2173
|
+
const step = 1 / (samples - 1);
|
|
2174
|
+
const interpolant = this._getInterpolant(samples);
|
|
2175
|
+
const times = interpolant.parameterPositions;
|
|
2176
|
+
const values = interpolant.sampleValues;
|
|
2177
|
+
const point = this.createCurvePoint();
|
|
2178
|
+
for(let i = 0; i < samples; i++){
|
|
2179
|
+
this.getPoint(i * step, point);
|
|
2180
|
+
times[i] = point.x;
|
|
2181
|
+
values[i] = point.y;
|
|
2182
|
+
}
|
|
2183
|
+
}
|
|
2184
|
+
evaluate(t) {
|
|
2185
|
+
if (this.needsUpdate) {
|
|
2186
|
+
this.needsUpdate = false;
|
|
2187
|
+
this.resample();
|
|
2188
|
+
}
|
|
2189
|
+
return this._interpolant.evaluate(t)[0];
|
|
2190
|
+
}
|
|
2191
|
+
getPoint(t, out) {
|
|
2192
|
+
const points = this.points;
|
|
2193
|
+
if (t <= 0) {
|
|
2194
|
+
return out.set(t, points[0].y);
|
|
2195
|
+
}
|
|
2196
|
+
if (t >= 1) {
|
|
2197
|
+
return out.set(t, points[points.length - 1].y);
|
|
2198
|
+
}
|
|
2199
|
+
const p = (points.length - 1) * t;
|
|
2200
|
+
const intPoint = Math.floor(p);
|
|
2201
|
+
const weight = p - intPoint;
|
|
2202
|
+
const p0 = points[intPoint === 0 ? intPoint : intPoint - 1];
|
|
2203
|
+
const p1 = points[intPoint];
|
|
2204
|
+
const p2 = points[intPoint > points.length - 2 ? points.length - 1 : intPoint + 1];
|
|
2205
|
+
const p3 = points[intPoint > points.length - 3 ? points.length - 1 : intPoint + 2];
|
|
2206
|
+
if (p1.mode === 1 || p0 === p1 && p2.mode === 1) {
|
|
2207
|
+
return p1.lerp(p2, weight, out);
|
|
2208
|
+
}
|
|
2209
|
+
return out.set(clamp$1(catmullRom(weight, p0.x, p1.x, p2.x, p3.x), 0, 1), clamp$1(catmullRom(weight, p0.y, p1.y, p2.y, p3.y), 0, 1));
|
|
2210
|
+
}
|
|
2211
|
+
constructor(name = "", points = [
|
|
2212
|
+
new CurvePoint(0, 0),
|
|
2213
|
+
new CurvePoint(1, 1)
|
|
2214
|
+
]){
|
|
2215
|
+
this.name = name;
|
|
2216
|
+
this.points = points;
|
|
2217
|
+
this.needsUpdate = true;
|
|
2218
|
+
this.isAnimationCurve = true;
|
|
2219
|
+
this._samples = 100;
|
|
2220
|
+
this._interpolant = new LinearInterpolant(new Float32Array(100), new Float32Array(100), 1, new Float32Array(100));
|
|
2221
|
+
}
|
|
2222
|
+
}
|
|
2008
2223
|
|
|
2009
|
-
const
|
|
2224
|
+
const { floor } = Math;
|
|
2225
|
+
// Copyright (C) 2016 Keijiro Takahashi
|
|
2226
|
+
// https://mrl.cs.nyu.edu/~perlin/noise/
|
|
2227
|
+
class Perlin {
|
|
2228
|
+
static Noise(x, y, z) {
|
|
2229
|
+
let fade = Perlin._Fade;
|
|
2230
|
+
let grad = Perlin._Grad;
|
|
2231
|
+
let lerp = Perlin._Lerp;
|
|
2232
|
+
let p = Perlin._Permutation;
|
|
2233
|
+
if (y !== undefined && z !== undefined) {
|
|
2234
|
+
let xi = floor(x);
|
|
2235
|
+
let yi = floor(y);
|
|
2236
|
+
let zi = floor(z);
|
|
2237
|
+
let X = xi & 0xff; // FIND UNIT CUBE THAT
|
|
2238
|
+
let Y = yi & 0xff; // CONTAINS POINT.
|
|
2239
|
+
let Z = zi & 0xff;
|
|
2240
|
+
x -= xi; // FIND RELATIVE X,Y,Z
|
|
2241
|
+
y -= yi; // OF POINT IN CUBE.
|
|
2242
|
+
z -= zi;
|
|
2243
|
+
let u = fade(x); // COMPUTE FADE CURVES
|
|
2244
|
+
let v = fade(y); // FOR EACH OF X,Y,Z.
|
|
2245
|
+
let w = fade(z);
|
|
2246
|
+
let A = p[X] + Y, AA = p[A] + Z, AB = p[A + 1] + Z; // HASH COORDINATES OF
|
|
2247
|
+
let B = p[X + 1] + Y, BA = p[B] + Z, BB = p[B + 1] + Z; // THE 8 CUBE CORNERS,
|
|
2248
|
+
return lerp(w, lerp(v, lerp(u, grad(p[AA], x, y, z), grad(p[BA], x - 1, y, z)), lerp(u, grad(p[AB], x, y - 1, z), grad(p[BB], x - 1, y - 1, z))), lerp(v, lerp(u, grad(p[AA + 1], x, y, z - 1), grad(p[BA + 1], x - 1, y, z - 1)), lerp(u, grad(p[AB + 1], x, y - 1, z - 1), grad(p[BB + 1], x - 1, y - 1, z - 1))));
|
|
2249
|
+
} else if (y !== undefined) {
|
|
2250
|
+
let xi = floor(x);
|
|
2251
|
+
let yi = floor(y);
|
|
2252
|
+
let X = xi & 0xff;
|
|
2253
|
+
let Y = yi & 0xff;
|
|
2254
|
+
x -= xi;
|
|
2255
|
+
y -= yi;
|
|
2256
|
+
let u = fade(x);
|
|
2257
|
+
let v = fade(y);
|
|
2258
|
+
let A = p[X] + Y & 0xff;
|
|
2259
|
+
let B = p[X + 1] + Y & 0xff;
|
|
2260
|
+
return lerp(v, lerp(u, grad(p[A], x, y), grad(p[B], x - 1, y)), lerp(u, grad(p[A + 1], x, y - 1), grad(p[B + 1], x - 1, y - 1)));
|
|
2261
|
+
} else {
|
|
2262
|
+
let xi = floor(x);
|
|
2263
|
+
let X = xi & 0xff;
|
|
2264
|
+
x -= xi;
|
|
2265
|
+
let u = fade(x);
|
|
2266
|
+
return lerp(u, grad(p[X], x), grad(p[X + 1], x - 1));
|
|
2267
|
+
}
|
|
2268
|
+
}
|
|
2269
|
+
static Fbm(octave, x, y, z) {
|
|
2270
|
+
let f = 0;
|
|
2271
|
+
let w = 0.5;
|
|
2272
|
+
let noise = Perlin.Noise;
|
|
2273
|
+
if (y !== undefined && z !== undefined) {
|
|
2274
|
+
for(let i = 0; i < octave; i++){
|
|
2275
|
+
f += w * noise(x, y, z);
|
|
2276
|
+
x *= 2.0;
|
|
2277
|
+
y *= 2.0;
|
|
2278
|
+
z *= 2.0;
|
|
2279
|
+
w *= 0.5;
|
|
2280
|
+
}
|
|
2281
|
+
} else if (y !== undefined) {
|
|
2282
|
+
for(let i = 0; i < octave; i++){
|
|
2283
|
+
f += w * noise(x, y);
|
|
2284
|
+
x *= 2.0;
|
|
2285
|
+
y *= 2.0;
|
|
2286
|
+
w *= 0.5;
|
|
2287
|
+
}
|
|
2288
|
+
} else {
|
|
2289
|
+
for(let i = 0; i < octave; i++){
|
|
2290
|
+
f += w * noise(x);
|
|
2291
|
+
x *= 2.0;
|
|
2292
|
+
w *= 0.5;
|
|
2293
|
+
}
|
|
2294
|
+
}
|
|
2295
|
+
return f;
|
|
2296
|
+
}
|
|
2297
|
+
static _Fade(t) {
|
|
2298
|
+
return t * t * t * (t * (t * 6 - 15) + 10);
|
|
2299
|
+
}
|
|
2300
|
+
static _Lerp(t, a, b) {
|
|
2301
|
+
return a + t * (b - a);
|
|
2302
|
+
}
|
|
2303
|
+
static _Grad(hash, x, y, z) {
|
|
2304
|
+
if (y !== undefined && z !== undefined) {
|
|
2305
|
+
let h = hash & 15; // CONVERT LO 4 BITS OF HASH CODE
|
|
2306
|
+
let u = h < 8 ? x : y, v = h < 4 ? y : h == 12 || h == 14 ? x : z;
|
|
2307
|
+
return ((h & 1) == 0 ? u : -u) + ((h & 2) == 0 ? v : -v);
|
|
2308
|
+
} else if (y !== undefined) {
|
|
2309
|
+
return ((hash & 1) == 0 ? x : -x) + ((hash & 2) == 0 ? y : -y);
|
|
2310
|
+
} else {
|
|
2311
|
+
return (hash & 1) == 0 ? x : -x;
|
|
2312
|
+
}
|
|
2313
|
+
}
|
|
2314
|
+
}
|
|
2315
|
+
Perlin._Permutation = [
|
|
2316
|
+
151,
|
|
2317
|
+
160,
|
|
2318
|
+
137,
|
|
2319
|
+
91,
|
|
2320
|
+
90,
|
|
2321
|
+
15,
|
|
2322
|
+
131,
|
|
2323
|
+
13,
|
|
2324
|
+
201,
|
|
2325
|
+
95,
|
|
2326
|
+
96,
|
|
2327
|
+
53,
|
|
2328
|
+
194,
|
|
2329
|
+
233,
|
|
2330
|
+
7,
|
|
2331
|
+
225,
|
|
2332
|
+
140,
|
|
2333
|
+
36,
|
|
2334
|
+
103,
|
|
2335
|
+
30,
|
|
2336
|
+
69,
|
|
2337
|
+
142,
|
|
2338
|
+
8,
|
|
2339
|
+
99,
|
|
2340
|
+
37,
|
|
2341
|
+
240,
|
|
2342
|
+
21,
|
|
2343
|
+
10,
|
|
2344
|
+
23,
|
|
2345
|
+
190,
|
|
2346
|
+
6,
|
|
2347
|
+
148,
|
|
2348
|
+
247,
|
|
2349
|
+
120,
|
|
2350
|
+
234,
|
|
2351
|
+
75,
|
|
2352
|
+
0,
|
|
2353
|
+
26,
|
|
2354
|
+
197,
|
|
2355
|
+
62,
|
|
2356
|
+
94,
|
|
2357
|
+
252,
|
|
2358
|
+
219,
|
|
2359
|
+
203,
|
|
2360
|
+
117,
|
|
2361
|
+
35,
|
|
2362
|
+
11,
|
|
2363
|
+
32,
|
|
2364
|
+
57,
|
|
2365
|
+
177,
|
|
2366
|
+
33,
|
|
2367
|
+
88,
|
|
2368
|
+
237,
|
|
2369
|
+
149,
|
|
2370
|
+
56,
|
|
2371
|
+
87,
|
|
2372
|
+
174,
|
|
2373
|
+
20,
|
|
2374
|
+
125,
|
|
2375
|
+
136,
|
|
2376
|
+
171,
|
|
2377
|
+
168,
|
|
2378
|
+
68,
|
|
2379
|
+
175,
|
|
2380
|
+
74,
|
|
2381
|
+
165,
|
|
2382
|
+
71,
|
|
2383
|
+
134,
|
|
2384
|
+
139,
|
|
2385
|
+
48,
|
|
2386
|
+
27,
|
|
2387
|
+
166,
|
|
2388
|
+
77,
|
|
2389
|
+
146,
|
|
2390
|
+
158,
|
|
2391
|
+
231,
|
|
2392
|
+
83,
|
|
2393
|
+
111,
|
|
2394
|
+
229,
|
|
2395
|
+
122,
|
|
2396
|
+
60,
|
|
2397
|
+
211,
|
|
2398
|
+
133,
|
|
2399
|
+
230,
|
|
2400
|
+
220,
|
|
2401
|
+
105,
|
|
2402
|
+
92,
|
|
2403
|
+
41,
|
|
2404
|
+
55,
|
|
2405
|
+
46,
|
|
2406
|
+
245,
|
|
2407
|
+
40,
|
|
2408
|
+
244,
|
|
2409
|
+
102,
|
|
2410
|
+
143,
|
|
2411
|
+
54,
|
|
2412
|
+
65,
|
|
2413
|
+
25,
|
|
2414
|
+
63,
|
|
2415
|
+
161,
|
|
2416
|
+
1,
|
|
2417
|
+
216,
|
|
2418
|
+
80,
|
|
2419
|
+
73,
|
|
2420
|
+
209,
|
|
2421
|
+
76,
|
|
2422
|
+
132,
|
|
2423
|
+
187,
|
|
2424
|
+
208,
|
|
2425
|
+
89,
|
|
2426
|
+
18,
|
|
2427
|
+
169,
|
|
2428
|
+
200,
|
|
2429
|
+
196,
|
|
2430
|
+
135,
|
|
2431
|
+
130,
|
|
2432
|
+
116,
|
|
2433
|
+
188,
|
|
2434
|
+
159,
|
|
2435
|
+
86,
|
|
2436
|
+
164,
|
|
2437
|
+
100,
|
|
2438
|
+
109,
|
|
2439
|
+
198,
|
|
2440
|
+
173,
|
|
2441
|
+
186,
|
|
2442
|
+
3,
|
|
2443
|
+
64,
|
|
2444
|
+
52,
|
|
2445
|
+
217,
|
|
2446
|
+
226,
|
|
2447
|
+
250,
|
|
2448
|
+
124,
|
|
2449
|
+
123,
|
|
2450
|
+
5,
|
|
2451
|
+
202,
|
|
2452
|
+
38,
|
|
2453
|
+
147,
|
|
2454
|
+
118,
|
|
2455
|
+
126,
|
|
2456
|
+
255,
|
|
2457
|
+
82,
|
|
2458
|
+
85,
|
|
2459
|
+
212,
|
|
2460
|
+
207,
|
|
2461
|
+
206,
|
|
2462
|
+
59,
|
|
2463
|
+
227,
|
|
2464
|
+
47,
|
|
2465
|
+
16,
|
|
2466
|
+
58,
|
|
2467
|
+
17,
|
|
2468
|
+
182,
|
|
2469
|
+
189,
|
|
2470
|
+
28,
|
|
2471
|
+
42,
|
|
2472
|
+
223,
|
|
2473
|
+
183,
|
|
2474
|
+
170,
|
|
2475
|
+
213,
|
|
2476
|
+
119,
|
|
2477
|
+
248,
|
|
2478
|
+
152,
|
|
2479
|
+
2,
|
|
2480
|
+
44,
|
|
2481
|
+
154,
|
|
2482
|
+
163,
|
|
2483
|
+
70,
|
|
2484
|
+
221,
|
|
2485
|
+
153,
|
|
2486
|
+
101,
|
|
2487
|
+
155,
|
|
2488
|
+
167,
|
|
2489
|
+
43,
|
|
2490
|
+
172,
|
|
2491
|
+
9,
|
|
2492
|
+
129,
|
|
2493
|
+
22,
|
|
2494
|
+
39,
|
|
2495
|
+
253,
|
|
2496
|
+
19,
|
|
2497
|
+
98,
|
|
2498
|
+
108,
|
|
2499
|
+
110,
|
|
2500
|
+
79,
|
|
2501
|
+
113,
|
|
2502
|
+
224,
|
|
2503
|
+
232,
|
|
2504
|
+
178,
|
|
2505
|
+
185,
|
|
2506
|
+
112,
|
|
2507
|
+
104,
|
|
2508
|
+
218,
|
|
2509
|
+
246,
|
|
2510
|
+
97,
|
|
2511
|
+
228,
|
|
2512
|
+
251,
|
|
2513
|
+
34,
|
|
2514
|
+
242,
|
|
2515
|
+
193,
|
|
2516
|
+
238,
|
|
2517
|
+
210,
|
|
2518
|
+
144,
|
|
2519
|
+
12,
|
|
2520
|
+
191,
|
|
2521
|
+
179,
|
|
2522
|
+
162,
|
|
2523
|
+
241,
|
|
2524
|
+
81,
|
|
2525
|
+
51,
|
|
2526
|
+
145,
|
|
2527
|
+
235,
|
|
2528
|
+
249,
|
|
2529
|
+
14,
|
|
2530
|
+
239,
|
|
2531
|
+
107,
|
|
2532
|
+
49,
|
|
2533
|
+
192,
|
|
2534
|
+
214,
|
|
2535
|
+
31,
|
|
2536
|
+
181,
|
|
2537
|
+
199,
|
|
2538
|
+
106,
|
|
2539
|
+
157,
|
|
2540
|
+
184,
|
|
2541
|
+
84,
|
|
2542
|
+
204,
|
|
2543
|
+
176,
|
|
2544
|
+
115,
|
|
2545
|
+
121,
|
|
2546
|
+
50,
|
|
2547
|
+
45,
|
|
2548
|
+
127,
|
|
2549
|
+
4,
|
|
2550
|
+
150,
|
|
2551
|
+
254,
|
|
2552
|
+
138,
|
|
2553
|
+
236,
|
|
2554
|
+
205,
|
|
2555
|
+
93,
|
|
2556
|
+
222,
|
|
2557
|
+
114,
|
|
2558
|
+
67,
|
|
2559
|
+
29,
|
|
2560
|
+
24,
|
|
2561
|
+
72,
|
|
2562
|
+
243,
|
|
2563
|
+
141,
|
|
2564
|
+
128,
|
|
2565
|
+
195,
|
|
2566
|
+
78,
|
|
2567
|
+
66,
|
|
2568
|
+
215,
|
|
2569
|
+
61,
|
|
2570
|
+
156,
|
|
2571
|
+
180,
|
|
2572
|
+
151
|
|
2573
|
+
];
|
|
2010
2574
|
|
|
2011
2575
|
const { clamp, degToRad } = MathUtils;
|
|
2012
2576
|
const { abs, tan } = Math;
|
|
@@ -3417,6 +3981,9 @@ class Viewer extends EventEmitter {
|
|
|
3417
3981
|
this._camera = camera;
|
|
3418
3982
|
return result;
|
|
3419
3983
|
}
|
|
3984
|
+
blit(renderTarget, material, lod, face) {
|
|
3985
|
+
Viewer.Blit(this._renderer, renderTarget, material, lod, face);
|
|
3986
|
+
}
|
|
3420
3987
|
compile(target) {
|
|
3421
3988
|
if (Array.isArray(target)) {
|
|
3422
3989
|
if (target.every((v)=>v.isMaterial)) {
|
|
@@ -3547,5 +4114,5 @@ class Plugin extends ObjectInstance {
|
|
|
3547
4114
|
}
|
|
3548
4115
|
}
|
|
3549
4116
|
|
|
3550
|
-
export { Box, CinestationBlendDefinition, CinestationBrain, Component, Easing, EventEmitter, FreelookVirtualCamera, Logger, ObjectInstance, Plane, Plugin, PropertyManager, Sphere, SystemInfo, Tween, TweenChain, TweenManager, Viewer, VirtualCamera, aEXRLoader, aFBXLoader, aGLTFLoader, aHDRLoader, aJSONLoader, aTextureLoader, getClassInstance, mixin, property };
|
|
4117
|
+
export { AnimationCurve, Box, CinestationBlendDefinition, CinestationBrain, Component, DeviceInput, Easing, EventEmitter, FInterpConstantTo, FInterpTo, FreelookVirtualCamera, Logger, ObjectInstance, Perlin, Plane, Plugin, PropertyManager, QInterpConstantTo, QInterpTo, Quat_AngularDistance, Quat_Equals, Quat_exponentialDamp, Quat_quarticDamp, Quat_smoothDamp, Sphere, SystemInfo, Tween, TweenChain, TweenManager, VInterpConstantTo, VInterpTo, Vec3_smoothDamp, Vector3_NEG_ONE, Vector3_ONE, Vector3_RIGHT, Vector3_UNIT_X, Vector3_UNIT_Y, Vector3_UNIT_Z, Vector3_UP, Vector3_ZERO, Viewer, VirtualCamera, aEXRLoader, aFBXLoader, aGLTFLoader, aHDRLoader, aJSONLoader, aTextureLoader, exponentialDamp, getClassInstance, mixin, property, quarticDamp, smoothDamp };
|
|
3551
4118
|
//# sourceMappingURL=module.js.map
|