@cascadetui/core 0.1.4 → 0.1.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/3d/Advanced3D.d.ts +161 -0
- package/3d/WGPURenderer.d.ts +13 -1
- package/3d/index.d.ts +1 -0
- package/3d.js +451 -6
- package/3d.js.map +5 -4
- package/Renderable.d.ts +4 -0
- package/{index-jx194wn1.js → index-rj3f00a6.js} +313 -36
- package/{index-jx194wn1.js.map → index-rj3f00a6.js.map} +7 -7
- package/index.js +205 -4
- package/index.js.map +4 -4
- package/lib/parse.mouse.d.ts +2 -2
- package/lib/stdin-buffer.d.ts +2 -1
- package/package.json +7 -7
- package/renderables/TextBufferRenderable.d.ts +16 -0
- package/renderables/TextNode.d.ts +8 -0
- package/renderer.d.ts +42 -2
- package/testing.js +1 -1
- package/types.d.ts +6 -0
package/3d.js
CHANGED
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
__export,
|
|
7
7
|
__require,
|
|
8
8
|
__toESM
|
|
9
|
-
} from "./index-
|
|
9
|
+
} from "./index-rj3f00a6.js";
|
|
10
10
|
|
|
11
11
|
// ../../node_modules/.bun/omggif@1.0.10/node_modules/omggif/omggif.js
|
|
12
12
|
var require_omggif = __commonJS((exports) => {
|
|
@@ -19501,7 +19501,13 @@ var require_any_base = __commonJS((exports, module) => {
|
|
|
19501
19501
|
});
|
|
19502
19502
|
|
|
19503
19503
|
// src/3d/WGPURenderer.ts
|
|
19504
|
-
import {
|
|
19504
|
+
import {
|
|
19505
|
+
PerspectiveCamera,
|
|
19506
|
+
Color,
|
|
19507
|
+
NoToneMapping,
|
|
19508
|
+
LinearSRGBColorSpace,
|
|
19509
|
+
PCFSoftShadowMap
|
|
19510
|
+
} from "three";
|
|
19505
19511
|
import { WebGPURenderer } from "three/webgpu";
|
|
19506
19512
|
import { createWebGPUDevice, setupGlobals } from "bun-webgpu";
|
|
19507
19513
|
|
|
@@ -31820,6 +31826,12 @@ class ThreeCliRenderer {
|
|
|
31820
31826
|
superSample;
|
|
31821
31827
|
backgroundColor = RGBA.fromValues(0, 0, 0, 1);
|
|
31822
31828
|
alpha = false;
|
|
31829
|
+
toneMapping = NoToneMapping;
|
|
31830
|
+
toneMappingExposure = 1;
|
|
31831
|
+
outputColorSpace = LinearSRGBColorSpace;
|
|
31832
|
+
shadows = false;
|
|
31833
|
+
shadowMapType = PCFSoftShadowMap;
|
|
31834
|
+
sortObjects = true;
|
|
31823
31835
|
threeRenderer;
|
|
31824
31836
|
canvas;
|
|
31825
31837
|
device = null;
|
|
@@ -31853,6 +31865,12 @@ class ThreeCliRenderer {
|
|
|
31853
31865
|
this.renderHeight = this.outputHeight * (this.superSample !== "none" /* NONE */ ? 2 : 1);
|
|
31854
31866
|
this.backgroundColor = options.backgroundColor ?? RGBA.fromValues(0, 0, 0, 1);
|
|
31855
31867
|
this.alpha = options.alpha ?? false;
|
|
31868
|
+
this.toneMapping = options.toneMapping ?? NoToneMapping;
|
|
31869
|
+
this.toneMappingExposure = options.toneMappingExposure ?? 1;
|
|
31870
|
+
this.outputColorSpace = options.outputColorSpace ?? LinearSRGBColorSpace;
|
|
31871
|
+
this.shadows = options.shadows ?? false;
|
|
31872
|
+
this.shadowMapType = options.shadowMapType ?? PCFSoftShadowMap;
|
|
31873
|
+
this.sortObjects = options.sortObjects ?? true;
|
|
31856
31874
|
if (process.env.CELL_ASPECT_RATIO) {
|
|
31857
31875
|
this._aspectRatio = parseFloat(process.env.CELL_ASPECT_RATIO);
|
|
31858
31876
|
}
|
|
@@ -31876,7 +31894,7 @@ class ThreeCliRenderer {
|
|
|
31876
31894
|
}
|
|
31877
31895
|
this.cliRenderer.on("debugOverlay:toggle" /* DEBUG_OVERLAY_TOGGLE */, this.debugToggleHandler);
|
|
31878
31896
|
this.cliRenderer.on("destroy" /* DESTROY */, this.destroyHandler);
|
|
31879
|
-
setupGlobals({ libPath: options.libPath });
|
|
31897
|
+
setupGlobals({ libPath: options.libPath ?? process.env.BUN_WEBGPU_LIB_PATH });
|
|
31880
31898
|
}
|
|
31881
31899
|
toggleDebugStats() {
|
|
31882
31900
|
this.doRenderStats = !this.doRenderStats;
|
|
@@ -31891,8 +31909,12 @@ class ThreeCliRenderer {
|
|
|
31891
31909
|
alpha: this.alpha
|
|
31892
31910
|
});
|
|
31893
31911
|
this.setBackgroundColor(this.backgroundColor);
|
|
31894
|
-
this.threeRenderer.toneMapping =
|
|
31895
|
-
this.threeRenderer.
|
|
31912
|
+
this.threeRenderer.toneMapping = this.toneMapping;
|
|
31913
|
+
this.threeRenderer.toneMappingExposure = this.toneMappingExposure;
|
|
31914
|
+
this.threeRenderer.outputColorSpace = this.outputColorSpace;
|
|
31915
|
+
this.threeRenderer.shadowMap.enabled = this.shadows;
|
|
31916
|
+
this.threeRenderer.shadowMap.type = this.shadowMapType;
|
|
31917
|
+
this.threeRenderer.sortObjects = this.sortObjects;
|
|
31896
31918
|
this.threeRenderer.setSize(this.renderWidth, this.renderHeight, false);
|
|
31897
31919
|
} catch (error) {
|
|
31898
31920
|
console.error("Error creating THREE.WebGPURenderer:", error);
|
|
@@ -32175,6 +32197,420 @@ class ThreeRenderable extends Renderable {
|
|
|
32175
32197
|
};
|
|
32176
32198
|
}
|
|
32177
32199
|
}
|
|
32200
|
+
// src/3d/Advanced3D.ts
|
|
32201
|
+
import {
|
|
32202
|
+
AmbientLight,
|
|
32203
|
+
BoxGeometry,
|
|
32204
|
+
CatmullRomCurve3,
|
|
32205
|
+
DirectionalLight,
|
|
32206
|
+
Euler,
|
|
32207
|
+
Fog,
|
|
32208
|
+
Group,
|
|
32209
|
+
InstancedMesh,
|
|
32210
|
+
Matrix4,
|
|
32211
|
+
Mesh,
|
|
32212
|
+
MeshStandardMaterial,
|
|
32213
|
+
Object3D,
|
|
32214
|
+
PlaneGeometry,
|
|
32215
|
+
PerspectiveCamera as PerspectiveCamera3,
|
|
32216
|
+
Quaternion,
|
|
32217
|
+
Scene as Scene3,
|
|
32218
|
+
TorusKnotGeometry,
|
|
32219
|
+
Vector2,
|
|
32220
|
+
Vector3
|
|
32221
|
+
} from "three";
|
|
32222
|
+
function createOrbitCameraRig(options = {}) {
|
|
32223
|
+
const camera = new PerspectiveCamera3(45, 1, 0.1, 1000);
|
|
32224
|
+
const orbit = new OrbitCameraController(camera, options);
|
|
32225
|
+
return { camera, orbit };
|
|
32226
|
+
}
|
|
32227
|
+
|
|
32228
|
+
class OrbitCameraController {
|
|
32229
|
+
camera;
|
|
32230
|
+
state;
|
|
32231
|
+
minRadius;
|
|
32232
|
+
maxRadius;
|
|
32233
|
+
minPolar;
|
|
32234
|
+
maxPolar;
|
|
32235
|
+
rotateSpeed;
|
|
32236
|
+
zoomSpeed;
|
|
32237
|
+
panSpeed;
|
|
32238
|
+
damping;
|
|
32239
|
+
azimuthVelocity = 0;
|
|
32240
|
+
polarVelocity = 0;
|
|
32241
|
+
zoomVelocity = 0;
|
|
32242
|
+
panVelocity = new Vector2(0, 0);
|
|
32243
|
+
constructor(camera, options = {}) {
|
|
32244
|
+
this.camera = camera;
|
|
32245
|
+
this.state = {
|
|
32246
|
+
target: options.target?.clone() ?? new Vector3(0, 0, 0),
|
|
32247
|
+
radius: options.radius ?? Math.max(0.001, camera.position.length() || 6),
|
|
32248
|
+
azimuth: options.azimuth ?? 0,
|
|
32249
|
+
polar: options.polar ?? Math.PI / 2
|
|
32250
|
+
};
|
|
32251
|
+
this.minRadius = options.minRadius ?? 0.2;
|
|
32252
|
+
this.maxRadius = options.maxRadius ?? 300;
|
|
32253
|
+
this.minPolar = options.minPolar ?? 0.01;
|
|
32254
|
+
this.maxPolar = options.maxPolar ?? Math.PI - 0.01;
|
|
32255
|
+
this.rotateSpeed = options.rotateSpeed ?? 1;
|
|
32256
|
+
this.zoomSpeed = options.zoomSpeed ?? 1;
|
|
32257
|
+
this.panSpeed = options.panSpeed ?? 1;
|
|
32258
|
+
this.damping = options.damping ?? 0.84;
|
|
32259
|
+
this.state.radius = this.clamp(this.state.radius, this.minRadius, this.maxRadius);
|
|
32260
|
+
this.state.polar = this.clamp(this.state.polar, this.minPolar, this.maxPolar);
|
|
32261
|
+
this.syncCamera();
|
|
32262
|
+
}
|
|
32263
|
+
getState() {
|
|
32264
|
+
return {
|
|
32265
|
+
target: this.state.target.clone(),
|
|
32266
|
+
radius: this.state.radius,
|
|
32267
|
+
azimuth: this.state.azimuth,
|
|
32268
|
+
polar: this.state.polar
|
|
32269
|
+
};
|
|
32270
|
+
}
|
|
32271
|
+
setTarget(target) {
|
|
32272
|
+
this.state.target.copy(target);
|
|
32273
|
+
this.syncCamera();
|
|
32274
|
+
}
|
|
32275
|
+
rotate(deltaAzimuth, deltaPolar) {
|
|
32276
|
+
this.azimuthVelocity += deltaAzimuth * this.rotateSpeed;
|
|
32277
|
+
this.polarVelocity += deltaPolar * this.rotateSpeed;
|
|
32278
|
+
}
|
|
32279
|
+
zoom(delta) {
|
|
32280
|
+
this.zoomVelocity += delta * this.zoomSpeed;
|
|
32281
|
+
}
|
|
32282
|
+
pan(deltaX, deltaY) {
|
|
32283
|
+
this.panVelocity.x += deltaX * this.panSpeed;
|
|
32284
|
+
this.panVelocity.y += deltaY * this.panSpeed;
|
|
32285
|
+
}
|
|
32286
|
+
update(deltaSeconds) {
|
|
32287
|
+
const dt = Math.max(0, deltaSeconds);
|
|
32288
|
+
this.state.azimuth += this.azimuthVelocity * dt;
|
|
32289
|
+
this.state.polar = this.clamp(this.state.polar + this.polarVelocity * dt, this.minPolar, this.maxPolar);
|
|
32290
|
+
this.state.radius = this.clamp(this.state.radius + this.zoomVelocity * dt, this.minRadius, this.maxRadius);
|
|
32291
|
+
if (this.panVelocity.lengthSq() > 0) {
|
|
32292
|
+
const forward = this.state.target.clone().sub(this.camera.position).normalize();
|
|
32293
|
+
const right = new Vector3().crossVectors(forward, this.camera.up).normalize();
|
|
32294
|
+
const up = this.camera.up.clone().normalize();
|
|
32295
|
+
this.state.target.addScaledVector(right, this.panVelocity.x * dt);
|
|
32296
|
+
this.state.target.addScaledVector(up, this.panVelocity.y * dt);
|
|
32297
|
+
}
|
|
32298
|
+
const dampingFactor = Math.pow(this.damping, Math.max(1, dt * 60));
|
|
32299
|
+
this.azimuthVelocity *= dampingFactor;
|
|
32300
|
+
this.polarVelocity *= dampingFactor;
|
|
32301
|
+
this.zoomVelocity *= dampingFactor;
|
|
32302
|
+
this.panVelocity.multiplyScalar(dampingFactor);
|
|
32303
|
+
this.syncCamera();
|
|
32304
|
+
}
|
|
32305
|
+
syncCamera() {
|
|
32306
|
+
const sinPolar = Math.sin(this.state.polar);
|
|
32307
|
+
const offset = new Vector3(this.state.radius * sinPolar * Math.sin(this.state.azimuth), this.state.radius * Math.cos(this.state.polar), this.state.radius * sinPolar * Math.cos(this.state.azimuth));
|
|
32308
|
+
this.camera.position.copy(this.state.target).add(offset);
|
|
32309
|
+
this.camera.lookAt(this.state.target);
|
|
32310
|
+
this.camera.updateProjectionMatrix();
|
|
32311
|
+
this.camera.updateMatrixWorld();
|
|
32312
|
+
}
|
|
32313
|
+
clamp(value, min, max) {
|
|
32314
|
+
return Math.min(max, Math.max(min, value));
|
|
32315
|
+
}
|
|
32316
|
+
}
|
|
32317
|
+
function createSeededRandom(seed) {
|
|
32318
|
+
let state = seed >>> 0;
|
|
32319
|
+
return () => {
|
|
32320
|
+
state = state * 1664525 + 1013904223 >>> 0;
|
|
32321
|
+
return state / 4294967296;
|
|
32322
|
+
};
|
|
32323
|
+
}
|
|
32324
|
+
function createInstancedScatter(geometry, material, options) {
|
|
32325
|
+
const count = Math.max(1, Math.floor(options.count));
|
|
32326
|
+
const extent = options.extent instanceof Vector3 ? options.extent.clone() : Array.isArray(options.extent) ? new Vector3(options.extent[0], options.extent[1], options.extent[2]) : new Vector3(20, 10, 20);
|
|
32327
|
+
const minScale = options.minScale ?? 0.35;
|
|
32328
|
+
const maxScale = options.maxScale ?? 1.8;
|
|
32329
|
+
const yRotationOnly = options.yRotationOnly ?? false;
|
|
32330
|
+
const random = createSeededRandom(options.seed ?? 12345);
|
|
32331
|
+
const mesh = new InstancedMesh(geometry, material, count);
|
|
32332
|
+
const tempMatrix = new Matrix4;
|
|
32333
|
+
const tempPosition = new Vector3;
|
|
32334
|
+
const tempScale = new Vector3;
|
|
32335
|
+
const tempQuaternion = new Quaternion;
|
|
32336
|
+
const tempEuler = new Euler;
|
|
32337
|
+
const maxExtent = new Vector3(extent.x * 0.5, extent.y * 0.5, extent.z * 0.5);
|
|
32338
|
+
let radius = 0;
|
|
32339
|
+
for (let i = 0;i < count; i++) {
|
|
32340
|
+
tempPosition.set((random() * 2 - 1) * maxExtent.x, (random() * 2 - 1) * maxExtent.y, (random() * 2 - 1) * maxExtent.z);
|
|
32341
|
+
if (yRotationOnly) {
|
|
32342
|
+
tempEuler.set(0, random() * Math.PI * 2, 0);
|
|
32343
|
+
} else {
|
|
32344
|
+
tempEuler.set(random() * Math.PI * 2, random() * Math.PI * 2, random() * Math.PI * 2);
|
|
32345
|
+
}
|
|
32346
|
+
tempQuaternion.setFromEuler(tempEuler);
|
|
32347
|
+
const uniformScale = minScale + random() * Math.max(0.0001, maxScale - minScale);
|
|
32348
|
+
tempScale.set(uniformScale, uniformScale, uniformScale);
|
|
32349
|
+
tempMatrix.compose(tempPosition, tempQuaternion, tempScale);
|
|
32350
|
+
mesh.setMatrixAt(i, tempMatrix);
|
|
32351
|
+
const dist = tempPosition.length() + uniformScale;
|
|
32352
|
+
if (dist > radius) {
|
|
32353
|
+
radius = dist;
|
|
32354
|
+
}
|
|
32355
|
+
}
|
|
32356
|
+
mesh.instanceMatrix.needsUpdate = true;
|
|
32357
|
+
mesh.computeBoundingSphere();
|
|
32358
|
+
return {
|
|
32359
|
+
mesh,
|
|
32360
|
+
center: new Vector3(0, 0, 0),
|
|
32361
|
+
radius
|
|
32362
|
+
};
|
|
32363
|
+
}
|
|
32364
|
+
function createMassiveScatterField(options) {
|
|
32365
|
+
const geometry = options.geometry ?? new BoxGeometry(1, 1, 1);
|
|
32366
|
+
const material = options.material ?? new MeshStandardMaterial({ color: options.color ?? 16777215, roughness: 0.9 });
|
|
32367
|
+
return createInstancedScatter(geometry, material, options);
|
|
32368
|
+
}
|
|
32369
|
+
|
|
32370
|
+
class KeyframeAnimator {
|
|
32371
|
+
target;
|
|
32372
|
+
keyframes;
|
|
32373
|
+
duration;
|
|
32374
|
+
loop;
|
|
32375
|
+
pingPong;
|
|
32376
|
+
time = 0;
|
|
32377
|
+
direction = 1;
|
|
32378
|
+
constructor(target, keyframes, options = {}) {
|
|
32379
|
+
if (keyframes.length < 2) {
|
|
32380
|
+
throw new Error("KeyframeAnimator requires at least two keyframes");
|
|
32381
|
+
}
|
|
32382
|
+
this.target = target;
|
|
32383
|
+
this.keyframes = [...keyframes].sort((a, b) => a.time - b.time);
|
|
32384
|
+
this.duration = this.keyframes[this.keyframes.length - 1].time;
|
|
32385
|
+
this.loop = options.loop ?? true;
|
|
32386
|
+
this.pingPong = options.pingPong ?? false;
|
|
32387
|
+
this.apply(0);
|
|
32388
|
+
}
|
|
32389
|
+
update(deltaSeconds) {
|
|
32390
|
+
if (this.duration <= 0)
|
|
32391
|
+
return;
|
|
32392
|
+
this.time += Math.max(0, deltaSeconds) * this.direction;
|
|
32393
|
+
if (this.pingPong) {
|
|
32394
|
+
if (this.time > this.duration) {
|
|
32395
|
+
this.time = this.duration;
|
|
32396
|
+
this.direction = -1;
|
|
32397
|
+
} else if (this.time < 0) {
|
|
32398
|
+
this.time = 0;
|
|
32399
|
+
this.direction = 1;
|
|
32400
|
+
}
|
|
32401
|
+
} else if (this.loop) {
|
|
32402
|
+
this.time = (this.time % this.duration + this.duration) % this.duration;
|
|
32403
|
+
} else {
|
|
32404
|
+
this.time = Math.min(this.duration, Math.max(0, this.time));
|
|
32405
|
+
}
|
|
32406
|
+
this.apply(this.time);
|
|
32407
|
+
}
|
|
32408
|
+
getTime() {
|
|
32409
|
+
return this.time;
|
|
32410
|
+
}
|
|
32411
|
+
apply(time) {
|
|
32412
|
+
let left = this.keyframes[0];
|
|
32413
|
+
let right = this.keyframes[this.keyframes.length - 1];
|
|
32414
|
+
for (let i = 0;i < this.keyframes.length - 1; i++) {
|
|
32415
|
+
const start = this.keyframes[i];
|
|
32416
|
+
const end = this.keyframes[i + 1];
|
|
32417
|
+
if (time >= start.time && time <= end.time) {
|
|
32418
|
+
left = start;
|
|
32419
|
+
right = end;
|
|
32420
|
+
break;
|
|
32421
|
+
}
|
|
32422
|
+
}
|
|
32423
|
+
const span = Math.max(0.000001, right.time - left.time);
|
|
32424
|
+
const t = this.clamp((time - left.time) / span, 0, 1);
|
|
32425
|
+
if (left.position && right.position) {
|
|
32426
|
+
this.target.position.copy(left.position).lerp(right.position, t);
|
|
32427
|
+
}
|
|
32428
|
+
if (left.scale && right.scale) {
|
|
32429
|
+
this.target.scale.copy(left.scale).lerp(right.scale, t);
|
|
32430
|
+
}
|
|
32431
|
+
if (left.rotation && right.rotation) {
|
|
32432
|
+
const startQ = new Quaternion().setFromEuler(left.rotation);
|
|
32433
|
+
const endQ = new Quaternion().setFromEuler(right.rotation);
|
|
32434
|
+
this.target.quaternion.copy(startQ).slerp(endQ, t);
|
|
32435
|
+
}
|
|
32436
|
+
this.target.updateMatrixWorld();
|
|
32437
|
+
}
|
|
32438
|
+
clamp(value, min, max) {
|
|
32439
|
+
return Math.min(max, Math.max(min, value));
|
|
32440
|
+
}
|
|
32441
|
+
}
|
|
32442
|
+
function createAnimatedTransformNode(keyframes, options = {}) {
|
|
32443
|
+
const node = new Object3D;
|
|
32444
|
+
const mapped = keyframes.map((keyframe) => ({
|
|
32445
|
+
time: keyframe.time,
|
|
32446
|
+
position: keyframe.position ? new Vector3(...keyframe.position) : undefined,
|
|
32447
|
+
rotation: keyframe.rotation ? new Euler(...keyframe.rotation) : undefined,
|
|
32448
|
+
scale: keyframe.scale ? new Vector3(...keyframe.scale) : undefined
|
|
32449
|
+
}));
|
|
32450
|
+
const animator = new KeyframeAnimator(node, mapped, options);
|
|
32451
|
+
return { node, animator };
|
|
32452
|
+
}
|
|
32453
|
+
function createCinematicScenePreset(options = {}) {
|
|
32454
|
+
const scene = new Scene3;
|
|
32455
|
+
scene.fog = new Fog(options.fogColor ?? 329226, options.fogNear ?? 8, options.fogFar ?? 120);
|
|
32456
|
+
const ambientLight = new AmbientLight(16777215, options.ambientIntensity ?? 0.2);
|
|
32457
|
+
const keyLight = new DirectionalLight(16773841, options.keyLightIntensity ?? 1.4);
|
|
32458
|
+
keyLight.position.set(14, 20, 12);
|
|
32459
|
+
const fillLight = new DirectionalLight(10405887, options.fillLightIntensity ?? 0.75);
|
|
32460
|
+
fillLight.position.set(-12, 8, 10);
|
|
32461
|
+
const rimLight = new DirectionalLight(16758159, options.rimLightIntensity ?? 0.9);
|
|
32462
|
+
rimLight.position.set(0, 8, -16);
|
|
32463
|
+
scene.add(ambientLight);
|
|
32464
|
+
scene.add(keyLight);
|
|
32465
|
+
scene.add(fillLight);
|
|
32466
|
+
scene.add(rimLight);
|
|
32467
|
+
const camera = new PerspectiveCamera3(options.cameraFov ?? 45, 1, options.cameraNear ?? 0.1, options.cameraFar ?? 1000);
|
|
32468
|
+
const orbit = new OrbitCameraController(camera, {
|
|
32469
|
+
radius: options.cameraRadius ?? 12,
|
|
32470
|
+
target: new Vector3(0, 0, 0),
|
|
32471
|
+
minRadius: 1,
|
|
32472
|
+
maxRadius: 300,
|
|
32473
|
+
damping: 0.86,
|
|
32474
|
+
rotateSpeed: 1,
|
|
32475
|
+
panSpeed: 0.8,
|
|
32476
|
+
zoomSpeed: 1.4
|
|
32477
|
+
});
|
|
32478
|
+
orbit.update(0);
|
|
32479
|
+
return {
|
|
32480
|
+
scene,
|
|
32481
|
+
camera,
|
|
32482
|
+
orbit,
|
|
32483
|
+
keyLight,
|
|
32484
|
+
fillLight,
|
|
32485
|
+
rimLight,
|
|
32486
|
+
ambientLight
|
|
32487
|
+
};
|
|
32488
|
+
}
|
|
32489
|
+
|
|
32490
|
+
class CameraRailController {
|
|
32491
|
+
camera;
|
|
32492
|
+
path;
|
|
32493
|
+
lookAtPath;
|
|
32494
|
+
speed;
|
|
32495
|
+
loop;
|
|
32496
|
+
t = 0;
|
|
32497
|
+
constructor(camera, points, options = {}) {
|
|
32498
|
+
if (points.length < 2) {
|
|
32499
|
+
throw new Error("CameraRailController requires at least two points");
|
|
32500
|
+
}
|
|
32501
|
+
this.camera = camera;
|
|
32502
|
+
this.speed = options.speed ?? 0.08;
|
|
32503
|
+
this.loop = options.loop ?? true;
|
|
32504
|
+
const pathPoints = points.map((point) => new Vector3(point.position[0], point.position[1], point.position[2]));
|
|
32505
|
+
const lookAtPoints = points.map((point) => {
|
|
32506
|
+
const lookAt = point.lookAt ?? [0, 0, 0];
|
|
32507
|
+
return new Vector3(lookAt[0], lookAt[1], lookAt[2]);
|
|
32508
|
+
});
|
|
32509
|
+
this.path = new CatmullRomCurve3(pathPoints, this.loop, "catmullrom", 0.5);
|
|
32510
|
+
this.lookAtPath = new CatmullRomCurve3(lookAtPoints, this.loop, "catmullrom", 0.5);
|
|
32511
|
+
this.update(0);
|
|
32512
|
+
}
|
|
32513
|
+
update(deltaSeconds) {
|
|
32514
|
+
const dt = Math.max(0, deltaSeconds);
|
|
32515
|
+
this.t += dt * this.speed;
|
|
32516
|
+
if (this.loop) {
|
|
32517
|
+
this.t = this.t % 1;
|
|
32518
|
+
} else {
|
|
32519
|
+
this.t = Math.min(1, this.t);
|
|
32520
|
+
}
|
|
32521
|
+
const position = this.path.getPointAt(this.t);
|
|
32522
|
+
const lookAt = this.lookAtPath.getPointAt(this.t);
|
|
32523
|
+
this.camera.position.copy(position);
|
|
32524
|
+
this.camera.lookAt(lookAt);
|
|
32525
|
+
this.camera.updateProjectionMatrix();
|
|
32526
|
+
this.camera.updateMatrixWorld();
|
|
32527
|
+
}
|
|
32528
|
+
getProgress() {
|
|
32529
|
+
return this.t;
|
|
32530
|
+
}
|
|
32531
|
+
setProgress(progress) {
|
|
32532
|
+
this.t = this.loop ? (progress % 1 + 1) % 1 : Math.min(1, Math.max(0, progress));
|
|
32533
|
+
this.update(0);
|
|
32534
|
+
}
|
|
32535
|
+
}
|
|
32536
|
+
function createShowcaseScene(options = {}) {
|
|
32537
|
+
const preset = createCinematicScenePreset({
|
|
32538
|
+
cameraRadius: 18,
|
|
32539
|
+
keyLightIntensity: 1.6,
|
|
32540
|
+
fillLightIntensity: 0.9,
|
|
32541
|
+
rimLightIntensity: 1.1
|
|
32542
|
+
});
|
|
32543
|
+
const floor = new Mesh(new PlaneGeometry(220, 220, 1, 1), new MeshStandardMaterial({
|
|
32544
|
+
color: 987417,
|
|
32545
|
+
roughness: 0.95,
|
|
32546
|
+
metalness: 0.05
|
|
32547
|
+
}));
|
|
32548
|
+
floor.rotation.x = -Math.PI / 2;
|
|
32549
|
+
floor.position.y = -3.2;
|
|
32550
|
+
floor.receiveShadow = true;
|
|
32551
|
+
preset.scene.add(floor);
|
|
32552
|
+
const scatter = createMassiveScatterField({
|
|
32553
|
+
count: options.instanceCount ?? 14000,
|
|
32554
|
+
seed: options.seed ?? 4242,
|
|
32555
|
+
extent: options.worldExtent ?? [180, 28, 180],
|
|
32556
|
+
minScale: 0.2,
|
|
32557
|
+
maxScale: 2.4,
|
|
32558
|
+
color: 9418751
|
|
32559
|
+
});
|
|
32560
|
+
scatter.mesh.castShadow = true;
|
|
32561
|
+
scatter.mesh.receiveShadow = true;
|
|
32562
|
+
const cluster = new Group;
|
|
32563
|
+
cluster.add(scatter.mesh);
|
|
32564
|
+
preset.scene.add(cluster);
|
|
32565
|
+
const focusNode = new Mesh(new TorusKnotGeometry(1.3, 0.42, 220, 48), new MeshStandardMaterial({
|
|
32566
|
+
color: 16766858,
|
|
32567
|
+
roughness: 0.35,
|
|
32568
|
+
metalness: 0.7,
|
|
32569
|
+
emissive: 2365194,
|
|
32570
|
+
emissiveIntensity: 0.5
|
|
32571
|
+
}));
|
|
32572
|
+
focusNode.castShadow = true;
|
|
32573
|
+
focusNode.receiveShadow = true;
|
|
32574
|
+
focusNode.position.set(0, 0, 0);
|
|
32575
|
+
preset.scene.add(focusNode);
|
|
32576
|
+
const { node: animatedFocus, animator: focusAnimator } = createAnimatedTransformNode([
|
|
32577
|
+
{ time: 0, position: [0, -0.6, 0], rotation: [0, 0, 0], scale: [0.9, 0.9, 0.9] },
|
|
32578
|
+
{ time: 2.5, position: [0, 0.6, 0], rotation: [0, Math.PI, 0], scale: [1.1, 1.1, 1.1] },
|
|
32579
|
+
{ time: 5, position: [0, -0.6, 0], rotation: [0, Math.PI * 2, 0], scale: [0.9, 0.9, 0.9] }
|
|
32580
|
+
], { loop: true });
|
|
32581
|
+
const rail = new CameraRailController(preset.camera, [
|
|
32582
|
+
{ position: [0, 6, 24], lookAt: [0, 0, 0] },
|
|
32583
|
+
{ position: [22, 5, 16], lookAt: [0, 0, 0] },
|
|
32584
|
+
{ position: [28, 7, -4], lookAt: [0, 0, 0] },
|
|
32585
|
+
{ position: [8, 9, -24], lookAt: [0, 0, 0] },
|
|
32586
|
+
{ position: [-20, 6, -14], lookAt: [0, 0, 0] },
|
|
32587
|
+
{ position: [-24, 8, 10], lookAt: [0, 0, 0] }
|
|
32588
|
+
], { loop: true, speed: 0.035 });
|
|
32589
|
+
const startY = focusNode.position.y;
|
|
32590
|
+
let time = 0;
|
|
32591
|
+
return {
|
|
32592
|
+
scene: preset.scene,
|
|
32593
|
+
camera: preset.camera,
|
|
32594
|
+
orbit: preset.orbit,
|
|
32595
|
+
rail,
|
|
32596
|
+
focusNode,
|
|
32597
|
+
update: (deltaSeconds) => {
|
|
32598
|
+
const dt = Math.max(0, deltaSeconds);
|
|
32599
|
+
time += dt;
|
|
32600
|
+
focusAnimator.update(dt);
|
|
32601
|
+
focusNode.position.x = animatedFocus.position.x;
|
|
32602
|
+
focusNode.position.y = startY + animatedFocus.position.y;
|
|
32603
|
+
focusNode.position.z = animatedFocus.position.z;
|
|
32604
|
+
focusNode.quaternion.copy(animatedFocus.quaternion);
|
|
32605
|
+
focusNode.scale.copy(animatedFocus.scale);
|
|
32606
|
+
cluster.rotation.y += dt * 0.08;
|
|
32607
|
+
const pulse = 0.9 + (Math.sin(time * 1.7) + 1) * 0.35;
|
|
32608
|
+
preset.keyLight.intensity = 1.2 + pulse * 0.4;
|
|
32609
|
+
preset.fillLight.intensity = 0.7 + pulse * 0.2;
|
|
32610
|
+
preset.rimLight.intensity = 0.8 + pulse * 0.25;
|
|
32611
|
+
}
|
|
32612
|
+
};
|
|
32613
|
+
}
|
|
32178
32614
|
// src/3d/TextureUtils.ts
|
|
32179
32615
|
import { Color as Color2, DataTexture, NearestFilter, ClampToEdgeWrapping, RGBAFormat, UnsignedByteType } from "three";
|
|
32180
32616
|
class TextureUtils {
|
|
@@ -34009,6 +34445,12 @@ class SpriteResourceManager {
|
|
|
34009
34445
|
// src/3d.ts
|
|
34010
34446
|
import * as THREE6 from "three";
|
|
34011
34447
|
export {
|
|
34448
|
+
createShowcaseScene,
|
|
34449
|
+
createOrbitCameraRig,
|
|
34450
|
+
createMassiveScatterField,
|
|
34451
|
+
createInstancedScatter,
|
|
34452
|
+
createCinematicScenePreset,
|
|
34453
|
+
createAnimatedTransformNode,
|
|
34012
34454
|
TiledSprite,
|
|
34013
34455
|
ThreeRenderable,
|
|
34014
34456
|
ThreeCliRenderer,
|
|
@@ -34028,14 +34470,17 @@ export {
|
|
|
34028
34470
|
PlanckPhysicsWorld,
|
|
34029
34471
|
PhysicsExplosionManager,
|
|
34030
34472
|
PhysicsExplodingSpriteEffect,
|
|
34473
|
+
OrbitCameraController,
|
|
34031
34474
|
MeshPool,
|
|
34475
|
+
KeyframeAnimator,
|
|
34032
34476
|
InstanceManager,
|
|
34033
34477
|
ExplosionManager,
|
|
34034
34478
|
ExplodingSpriteEffect,
|
|
34035
34479
|
DEFAULT_PHYSICS_EXPLOSION_PARAMETERS,
|
|
34036
34480
|
DEFAULT_EXPLOSION_PARAMETERS,
|
|
34481
|
+
CameraRailController,
|
|
34037
34482
|
CLICanvas
|
|
34038
34483
|
};
|
|
34039
34484
|
|
|
34040
|
-
//# debugId=
|
|
34485
|
+
//# debugId=290FDC6E12ED7E0364756E2164756E21
|
|
34041
34486
|
//# sourceMappingURL=3d.js.map
|