@tresjs/cientos 5.4.0 → 5.6.0

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.
@@ -1,14 +1,14 @@
1
1
  /**
2
2
  * name: @tresjs/cientos
3
- * version: v5.4.0
3
+ * version: v5.6.0
4
4
  * (c) 2026
5
5
  * description: Collection of useful helpers and fully functional, ready-made abstractions for Tres
6
6
  * author: Alvaro Saburido <hola@alvarosaburido.dev> (https://github.com/alvarosabu/)
7
7
  */
8
8
  import { Fragment, Suspense, computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, createVNode, defineComponent, inject, isReactive, isRef, mergeDefaults, mergeProps, nextTick, normalizeProps, onBeforeUnmount, onMounted, onUnmounted, openBlock, provide, reactive, ref, render, renderList, renderSlot, shallowReactive, shallowRef, toRaw, toRefs, toValue, triggerRef, unref, useAttrs, useSlots, watch, watchEffect, withAsyncContext, withCtx } from "vue";
9
- import { buildGraph, extend, isObject3D, logError, logWarning, normalizeColor, normalizeVectorFlexibleParam, useLoader, useLoop, useTres, useTresContext } from "@tresjs/core";
9
+ import { buildGraph, createTimer, extend, isObject3D, logError, logWarning, normalizeColor, normalizeVectorFlexibleParam, useLoader, useLoop, useTres, useTresContext } from "@tresjs/core";
10
10
  import * as THREE from "three";
11
- import { AdditiveBlending, AlwaysStencilFunc, AnimationMixer, Audio, AudioListener, AudioLoader, BackSide, Box2, Box3, BoxGeometry, BufferAttribute, BufferGeometry, Camera, CatmullRomCurve3, ClampToEdgeWrapping, Clock, Color, CubeCamera, CubeReflectionMapping, CubeTextureLoader, CubicBezierCurve3, DataTexture, DefaultLoadingManager, DepthTexture, DirectionalLight, DoubleSide, EdgesGeometry, EqualStencilFunc, EquirectangularReflectionMapping, Euler, FloatType, FramebufferTexture, FrontSide, Group, HalfFloatType, IcosahedronGeometry, InstancedMesh, InterleavedBuffer, InterleavedBufferAttribute, KeepStencilOp, LOD, LinearFilter, MOUSE, MathUtils, Matrix4, Mesh, MeshBasicMaterial, MeshDepthMaterial, MeshLambertMaterial, MeshStandardMaterial, NearestFilter, NoBlending, NotEqualStencilFunc, Object3D, OrthographicCamera, PerspectiveCamera, Plane, PlaneGeometry, Points, PointsMaterial, QuadraticBezierCurve3, Quaternion, REVISION, RGBAFormat, RawShaderMaterial, Raycaster, RepeatWrapping, ReplaceStencilOp, Scene, ShaderChunk, ShaderMaterial, ShapeGeometry, SkinnedMesh, Sphere, Spherical, TOUCH, TangentSpaceNormalMap, Texture, TextureLoader, UVMapping, Uniform, UniformsUtils, UnsignedByteType, Vector2, Vector3, Vector4, VideoTexture, WebGLCubeRenderTarget, WebGLRenderTarget, WebGLRenderer } from "three";
11
+ import { AdditiveBlending, AlwaysStencilFunc, AnimationMixer, Audio, AudioListener, AudioLoader, BackSide, Box2, Box3, BoxGeometry, BufferAttribute, BufferGeometry, Camera, CatmullRomCurve3, ClampToEdgeWrapping, Color, CubeCamera, CubeReflectionMapping, CubeTextureLoader, CubicBezierCurve3, DataTexture, DefaultLoadingManager, DepthTexture, DirectionalLight, DoubleSide, EdgesGeometry, EqualStencilFunc, EquirectangularReflectionMapping, Euler, FloatType, FramebufferTexture, FrontSide, Group, HalfFloatType, IcosahedronGeometry, InstancedMesh, InterleavedBuffer, InterleavedBufferAttribute, KeepStencilOp, LOD, LinearFilter, MOUSE, MathUtils, Matrix4, Mesh, MeshBasicMaterial, MeshDepthMaterial, MeshLambertMaterial, MeshStandardMaterial, NearestFilter, NoBlending, NotEqualStencilFunc, Object3D, OrthographicCamera, PerspectiveCamera, Plane, PlaneGeometry, Points, PointsMaterial, QuadraticBezierCurve3, Quaternion, REVISION, RGBAFormat, RawShaderMaterial, Raycaster, RepeatWrapping, ReplaceStencilOp, Scene, ShaderChunk, ShaderMaterial, ShapeGeometry, SkinnedMesh, Sphere, Spherical, TOUCH, TangentSpaceNormalMap, Texture, TextureLoader, UVMapping, Uniform, UniformsUtils, UnsignedByteType, Vector2, Vector3, Vector4, VideoTexture, WebGLCubeRenderTarget, WebGLRenderTarget, WebGLRenderer } from "three";
12
12
  import { tryOnScopeDispose, useDebounceFn, useElementSize, useEventListener, useMagicKeys, useMouse, useScroll, useWindowScroll, useWindowSize, watchThrottled, whenever } from "@vueuse/core";
13
13
  import { DRACOLoader, FBXLoader, FontLoader, GLTFExporter, GLTFLoader, HorizontalBlurShader, Line2, LineGeometry, LineMaterial, MapControls, MarchingCubes, MeshSurfaceSampler, OrbitControls, PointerLockControls, PositionalAudioHelper, RGBELoader, Reflector, RoundedBoxGeometry, SVGLoader, SimplexNoise, Sky, TextGeometry, TransformControls, VerticalBlurShader, Water, toCreasedNormals } from "three-stdlib";
14
14
  import BaseCameraControls, { default as CameraControls } from "camera-controls";
@@ -5417,7 +5417,8 @@ var HolographicMaterial = class extends ShaderMaterial {
5417
5417
  blinkFresnelOnly: new Uniform(parameters.blinkFresnelOnly !== void 0 ? parameters.blinkFresnelOnly : true),
5418
5418
  hologramOpacity: new Uniform(parameters.hologramOpacity !== void 0 ? parameters.hologramOpacity : 1)
5419
5419
  };
5420
- this.clock = new Clock();
5420
+ this.clock = createTimer();
5421
+ this.clock.start();
5421
5422
  this.setValues(parameters);
5422
5423
  this.depthTest = parameters.depthTest !== void 0 ? parameters.depthTest : false;
5423
5424
  this.blending = parameters.blendMode !== void 0 ? parameters.blendMode : AdditiveBlending;
@@ -5425,7 +5426,8 @@ var HolographicMaterial = class extends ShaderMaterial {
5425
5426
  this.side = parameters.side !== void 0 ? parameters.side : FrontSide;
5426
5427
  }
5427
5428
  update() {
5428
- this.uniforms.time.value = this.clock.getElapsedTime();
5429
+ this.clock.update();
5430
+ this.uniforms.time.value = this.clock.getElapsed();
5429
5431
  }
5430
5432
  };
5431
5433
  var HolographicMaterialParameters_default = HolographicMaterial;
@@ -7494,7 +7496,7 @@ const useBVH = (target, { enabled = true, firstHitOnly = false, splitStrategy =
7494
7496
  whenever(() => toValue(target), () => {
7495
7497
  const objectValue = toValue(target);
7496
7498
  if (objectValue && toValue(enabled)) applyBVH(objectValue);
7497
- });
7499
+ }, { immediate: true });
7498
7500
  watch(() => toValue(enabled), (enabled$1) => {
7499
7501
  if (enabled$1) {
7500
7502
  const objectValue = toValue(target);
@@ -10438,15 +10440,41 @@ var Ocean_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineCo
10438
10440
  type: null,
10439
10441
  required: false,
10440
10442
  default: FrontSide
10443
+ },
10444
+ speed: {
10445
+ type: Number,
10446
+ required: false,
10447
+ default: 1
10441
10448
  }
10442
10449
  },
10443
10450
  setup(__props, { expose: __expose }) {
10444
- const { textureWidth, textureHeight, waterNormals, sunDirection, sunColor, waterColor, distortionScale, size, clipBias, alpha, side } = toRefs(__props);
10451
+ const props = __props;
10452
+ const { waterNormals, sunColor, waterColor, distortionScale, size, alpha, speed } = toRefs(props);
10445
10453
  const { extend: extend$1, scene } = useTresContext();
10446
10454
  extend$1({ Water });
10447
10455
  const waterRef = shallowRef();
10448
10456
  const sunRef = shallowRef();
10449
10457
  const _fog = scene.value.fog !== void 0;
10458
+ function changeSunColor(val) {
10459
+ if (waterRef.value) waterRef.value.material.uniforms.sunColor.value.set(val);
10460
+ }
10461
+ function changeWaterColor(val) {
10462
+ if (waterRef.value) waterRef.value.material.uniforms.waterColor.value.set(val);
10463
+ }
10464
+ function changeDistortionScale(val) {
10465
+ if (waterRef.value) waterRef.value.material.uniforms.distortionScale.value = val;
10466
+ }
10467
+ function changeSize(val) {
10468
+ if (waterRef.value) waterRef.value.material.uniforms.size.value = val;
10469
+ }
10470
+ function changeAlpha(val) {
10471
+ if (waterRef.value) waterRef.value.material.uniforms.alpha.value = val;
10472
+ }
10473
+ watch(sunColor, changeSunColor);
10474
+ watch(waterColor, changeWaterColor);
10475
+ watch(distortionScale, changeDistortionScale);
10476
+ watch(size, changeSize);
10477
+ watch(alpha, changeAlpha);
10450
10478
  __expose({ instance: waterRef });
10451
10479
  scene.value.traverse((child) => {
10452
10480
  if (Object.prototype.hasOwnProperty.call(child, "isSky")) sunRef.value = child;
@@ -10460,29 +10488,30 @@ var Ocean_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineCo
10460
10488
  });
10461
10489
  const normalMap = new TextureLoader().load(waterNormals.value);
10462
10490
  normalMap.wrapS = normalMap.wrapT = RepeatWrapping;
10491
+ const initialParams = {
10492
+ textureWidth: props.textureWidth,
10493
+ textureHeight: props.textureHeight,
10494
+ waterNormals: normalMap,
10495
+ sunDirection: props.sunDirection,
10496
+ sunColor: props.sunColor,
10497
+ waterColor: props.waterColor,
10498
+ distortionScale: props.distortionScale,
10499
+ fog: _fog,
10500
+ size: props.size,
10501
+ clipBias: props.clipBias,
10502
+ alpha: props.alpha,
10503
+ side: props.side
10504
+ };
10463
10505
  const { onBeforeRender } = useLoop();
10464
10506
  onBeforeRender(({ delta }) => {
10465
- if (waterRef.value) waterRef.value.material.uniforms.time.value += delta;
10507
+ if (waterRef.value) waterRef.value.material.uniforms.time.value += delta * speed.value;
10466
10508
  });
10467
10509
  return (_ctx, _cache) => {
10468
10510
  return openBlock(), createElementBlock("TresWater", {
10469
10511
  ref_key: "waterRef",
10470
10512
  ref: waterRef,
10471
10513
  "rotation-x": -Math.PI / 2,
10472
- args: [void 0, {
10473
- textureWidth: unref(textureWidth),
10474
- textureHeight: unref(textureHeight),
10475
- waterNormals: unref(normalMap),
10476
- sunDirection: unref(sunDirection),
10477
- sunColor: unref(sunColor),
10478
- waterColor: unref(waterColor),
10479
- distortionScale: unref(distortionScale),
10480
- fog: _fog,
10481
- size: unref(size),
10482
- clipBias: unref(clipBias),
10483
- alpha: unref(alpha),
10484
- side: unref(side)
10485
- }]
10514
+ args: [void 0, initialParams]
10486
10515
  }, [renderSlot(_ctx.$slots, "default", {}, () => [_cache[0] || (_cache[0] = createElementVNode("TresPlaneGeometry", { args: [1e4, 1e4] }, null, -1))])], 8, _hoisted_1$8);
10487
10516
  };
10488
10517
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tresjs/cientos",
3
3
  "type": "module",
4
- "version": "5.4.0",
4
+ "version": "5.6.0",
5
5
  "description": "Collection of useful helpers and fully functional, ready-made abstractions for Tres",
6
6
  "author": "Alvaro Saburido <hola@alvarosaburido.dev> (https://github.com/alvarosabu/)",
7
7
  "license": "MIT",
@@ -38,7 +38,7 @@
38
38
  "access": "public"
39
39
  },
40
40
  "peerDependencies": {
41
- "@tresjs/core": "5.5.0",
41
+ "@tresjs/core": "5.7.0",
42
42
  "three": ">=0.133",
43
43
  "vue": ">=3.5.17"
44
44
  },
@@ -53,7 +53,7 @@
53
53
  },
54
54
  "devDependencies": {
55
55
  "@types/node": "^24.5.2",
56
- "@types/three": "^0.182.0",
56
+ "@types/three": "^0.183.0",
57
57
  "@typescript-eslint/eslint-plugin": "^8.42.0",
58
58
  "@typescript-eslint/parser": "^8.42.0",
59
59
  "@vitejs/plugin-vue": "^6.0.1",
@@ -63,7 +63,7 @@
63
63
  "pathe": "^2.0.3",
64
64
  "rollup-plugin-analyzer": "^4.0.0",
65
65
  "rollup-plugin-visualizer": "^6.0.3",
66
- "three": "^0.182.0",
66
+ "three": "^0.183.0",
67
67
  "tsdown": "0.18.3",
68
68
  "typescript": "^5.8.3",
69
69
  "vite": "^7.1.9",
@@ -72,8 +72,8 @@
72
72
  "vite-plugin-glsl": "^1.5.1",
73
73
  "vite-svg-loader": "^5.1.0",
74
74
  "vue-tsc": "^3.2.1",
75
- "@tresjs/eslint-config": "1.5.1",
76
- "@tresjs/core": "5.5.0"
75
+ "@tresjs/core": "5.7.0",
76
+ "@tresjs/eslint-config": "1.5.1"
77
77
  },
78
78
  "nx": {
79
79
  "implicitDependencies": [
@@ -83,6 +83,7 @@
83
83
  "scripts": {
84
84
  "dev": "cd playground/vue && pnpm dev",
85
85
  "build": "tsdown",
86
+ "build:analyze": "ANALYZE=true tsdown",
86
87
  "lint": "eslint .",
87
88
  "typecheck": "vue-tsc --noEmit",
88
89
  "lint:fix": "eslint . --fix"