@react-three/drei 9.88.1 → 9.88.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/core/AccumulativeShadows.cjs.js +1 -1
- package/core/AccumulativeShadows.js +8 -7
- package/core/ArcballControls.js +1 -1
- package/core/BBAnchor.js +2 -2
- package/core/Billboard.js +1 -1
- package/core/Bounds.js +1 -1
- package/core/CameraControls.js +1 -1
- package/core/CameraShake.js +1 -1
- package/core/CatmullRomLine.js +1 -1
- package/core/Caustics.cjs.js +1 -1
- package/core/Caustics.js +13 -12
- package/core/Center.js +1 -1
- package/core/Clone.js +1 -1
- package/core/Cloud.js +10 -10
- package/core/ContactShadows.js +1 -1
- package/core/CubicBezierLine.js +1 -1
- package/core/CurveModifier.js +1 -1
- package/core/Decal.js +1 -1
- package/core/Detailed.js +1 -1
- package/core/DeviceOrientationControls.js +1 -1
- package/core/Edges.js +1 -1
- package/core/Effects.js +1 -1
- package/core/Example.js +1 -1
- package/core/FaceControls.js +4 -4
- package/core/FaceLandmarker.js +1 -1
- package/core/Facemesh.d.ts +3 -3
- package/core/Facemesh.js +4 -4
- package/core/FirstPersonControls.js +1 -1
- package/core/Float.js +1 -1
- package/core/FlyControls.js +1 -1
- package/core/GizmoHelper.js +7 -7
- package/core/GizmoViewcube.js +3 -3
- package/core/Gltf.js +1 -1
- package/core/Grid.cjs.js +1 -1
- package/core/Grid.js +8 -7
- package/core/Image.cjs.js +1 -1
- package/core/Image.js +8 -7
- package/core/Instances.js +13 -13
- package/core/Lightformer.js +1 -1
- package/core/Line.js +1 -1
- package/core/MapControls.js +1 -1
- package/core/MarchingCubes.js +4 -4
- package/core/Mask.js +1 -1
- package/core/MeshDiscardMaterial.js +1 -1
- package/core/MeshDistortMaterial.js +1 -1
- package/core/MeshPortalMaterial.cjs.js +1 -1
- package/core/MeshPortalMaterial.js +6 -5
- package/core/MeshReflectorMaterial.cjs.js +1 -1
- package/core/MeshReflectorMaterial.js +4 -4
- package/core/MeshRefractionMaterial.cjs.js +1 -1
- package/core/MeshTransmissionMaterial.js +1 -1
- package/core/MeshWobbleMaterial.js +1 -1
- package/core/MotionPathControls.js +2 -2
- package/core/OrbitControls.js +1 -1
- package/core/OrthographicCamera.js +1 -1
- package/core/Outlines.cjs.js +1 -1
- package/core/Outlines.js +5 -4
- package/core/PerformanceMonitor.js +1 -1
- package/core/PerspectiveCamera.js +1 -1
- package/core/PointMaterial.cjs.js +1 -1
- package/core/PointMaterial.js +4 -3
- package/core/PointerLockControls.js +1 -1
- package/core/Points.js +11 -11
- package/core/PositionalAudio.js +1 -1
- package/core/QuadraticBezierLine.js +3 -3
- package/core/Reflector.cjs.js +1 -1
- package/core/Reflector.js +4 -5
- package/core/RenderCubeTexture.js +1 -1
- package/core/RenderTexture.js +1 -1
- package/core/Resize.js +1 -1
- package/core/RoundedBox.js +1 -1
- package/core/ScreenQuad.js +1 -1
- package/core/ScreenSpace.js +1 -1
- package/core/Segments.js +3 -3
- package/core/Shadow.js +1 -1
- package/core/Sky.js +1 -1
- package/core/Sparkles.cjs.js +1 -1
- package/core/Sparkles.js +4 -3
- package/core/SpotLight.cjs.js +1 -1
- package/core/Stage.cjs.js +1 -1
- package/core/Stars.cjs.js +1 -1
- package/core/Stars.js +4 -4
- package/core/Svg.js +1 -1
- package/core/Text.js +1 -1
- package/core/Text3D.js +1 -1
- package/core/TrackballControls.js +1 -1
- package/core/Trail.js +1 -1
- package/core/TransformControls.js +1 -1
- package/core/Wireframe.cjs.js +1 -1
- package/core/Wireframe.d.ts +2 -2
- package/core/Wireframe.js +4 -4
- package/core/index.cjs.js +1 -1
- package/core/index.js +1 -0
- package/core/meshBounds.js +4 -4
- package/core/shapes.js +19 -19
- package/core/useBVH.js +1 -1
- package/core/useProgress.js +1 -1
- package/helpers/constants.cjs.js +1 -0
- package/helpers/constants.d.ts +1 -0
- package/helpers/constants.js +6 -0
- package/index.cjs.js +1 -1
- package/materials/BlurPass.cjs.js +1 -1
- package/materials/ConvolutionMaterial.cjs.js +1 -1
- package/materials/ConvolutionMaterial.js +2 -1
- package/materials/DiscardMaterial.js +1 -1
- package/materials/MeshRefractionMaterial.cjs.js +1 -1
- package/materials/MeshRefractionMaterial.js +8 -7
- package/materials/SpotLightMaterial.cjs.js +1 -1
- package/materials/SpotLightMaterial.js +2 -1
- package/materials/WireframeMaterial.js +4 -4
- package/native/index.cjs.js +1 -1
- package/native/index.js +1 -0
- package/package.json +1 -1
- package/react-three-drei-0.0.0-semantic-release.tgz +0 -0
- package/web/Html.js +4 -4
- package/web/KeyboardControls.js +1 -1
- package/web/ScrollControls.js +3 -3
- package/web/Select.js +1 -1
- package/web/View.js +1 -1
- package/web/index.cjs.js +1 -1
- package/web/index.js +1 -0
- package/web/pivotControls/AxisArrow.js +4 -4
- package/web/pivotControls/AxisRotator.js +6 -6
- package/web/pivotControls/PlaneSlider.js +3 -3
- package/web/pivotControls/context.js +1 -1
- package/web/pivotControls/index.js +21 -21
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@babel/runtime/helpers/extends"),t=require("three"),r=require("react"),a=require("@react-three/fiber"),i=require("./shaderMaterial.cjs.js"),s=require("../materials/DiscardMaterial.cjs.js");function
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@babel/runtime/helpers/extends"),t=require("three"),r=require("react"),a=require("@react-three/fiber"),i=require("./shaderMaterial.cjs.js"),s=require("../materials/DiscardMaterial.cjs.js"),n=require("../helpers/constants.cjs.js");function o(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}function l(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(r){if("default"!==r){var a=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,a.get?a:{enumerable:!0,get:function(){return e[r]}})}})),t.default=e,Object.freeze(t)}var h=o(e),c=l(t),u=l(r);const d=u.createContext(null),p=i.shaderMaterial({color:new c.Color,blend:2,alphaTest:.75,opacity:0,map:null},"varying vec2 vUv;\n void main() {\n gl_Position = projectionMatrix * viewMatrix * modelMatrix * vec4(position, 1.);\n vUv = uv;\n }",`varying vec2 vUv;\n uniform sampler2D map;\n uniform vec3 color;\n uniform float opacity;\n uniform float alphaTest;\n uniform float blend;\n void main() {\n vec4 sampledDiffuseColor = texture2D(map, vUv);\n gl_FragColor = vec4(color * sampledDiffuseColor.r * blend, max(0.0, (1.0 - (sampledDiffuseColor.r + sampledDiffuseColor.g + sampledDiffuseColor.b) / alphaTest)) * opacity);\n #include <tonemapping_fragment>\n #include <${n.version>=154?"colorspace_fragment":"encodings_fragment"}>\n }`),f=u.forwardRef((({children:e,temporal:t,frames:r=40,limit:i=1/0,blend:s=20,scale:n=10,opacity:o=1,alphaTest:l=.75,color:h="black",colorBlend:c=2,resolution:f=1024,toneMapped:g=!0,...v},M)=>{a.extend({SoftShadowMaterial:p});const b=a.useThree((e=>e.gl)),w=a.useThree((e=>e.scene)),y=a.useThree((e=>e.camera)),x=a.useThree((e=>e.invalidate)),C=u.useRef(null),S=u.useRef(null),[j]=u.useState((()=>new m(b,w,f)));u.useLayoutEffect((()=>{j.configure(C.current)}),[]);const T=u.useMemo((()=>({lights:new Map,temporal:!!t,frames:Math.max(2,r),blend:Math.max(2,r===1/0?s:r),count:0,getMesh:()=>C.current,reset:()=>{j.clear();const e=C.current.material;e.opacity=0,e.alphaTest=0,T.count=0},update:(e=1)=>{const t=C.current.material;T.temporal?(t.opacity=Math.min(o,t.opacity+o/T.blend),t.alphaTest=Math.min(l,t.alphaTest+l/T.blend)):(t.opacity=o,t.alphaTest=l),S.current.visible=!0,j.prepare();for(let t=0;t<e;t++)T.lights.forEach((e=>e.update())),j.update(y,T.blend);S.current.visible=!1,j.finish()}})),[j,y,w,t,r,s,o,l]);return u.useLayoutEffect((()=>{T.reset(),T.temporal||T.frames===1/0||T.update(T.blend)})),u.useImperativeHandle(M,(()=>T),[T]),a.useFrame((()=>{(T.temporal||T.frames===1/0)&&T.count<T.frames&&T.count<i&&(x(),T.update(),T.count++)})),u.createElement("group",v,u.createElement("group",{traverse:()=>null,ref:S},u.createElement(d.Provider,{value:T},e)),u.createElement("mesh",{receiveShadow:!0,ref:C,scale:n,rotation:[-Math.PI/2,0,0]},u.createElement("planeGeometry",null),u.createElement("softShadowMaterial",{transparent:!0,depthWrite:!1,toneMapped:g,color:h,blend:c,map:j.progressiveLightMap2.texture})))})),g=u.forwardRef((({castShadow:e=!0,bias:t=.001,mapSize:r=512,size:a=5,near:i=.5,far:s=500,frames:o=1,position:l=[0,0,0],radius:p=1,amount:f=8,intensity:g=(n.version>=155?Math.PI:1),ambient:m=.5,...v},M)=>{const b=u.useRef(null),w=new c.Vector3(...l).length(),y=u.useContext(d),x=u.useCallback((()=>{let e;if(b.current)for(let t=0;t<b.current.children.length;t++)if(e=b.current.children[t],Math.random()>m)e.position.set(l[0]+c.MathUtils.randFloatSpread(p),l[1]+c.MathUtils.randFloatSpread(p),l[2]+c.MathUtils.randFloatSpread(p));else{let t=Math.acos(2*Math.random()-1)-Math.PI/2,r=2*Math.PI*Math.random();e.position.set(Math.cos(t)*Math.cos(r)*w,Math.abs(Math.cos(t)*Math.sin(r)*w),Math.sin(t)*w)}}),[p,m,w,...l]),C=u.useMemo((()=>({update:x})),[x]);return u.useImperativeHandle(M,(()=>C),[C]),u.useLayoutEffect((()=>{const e=b.current;return y&&y.lights.set(e.uuid,C),()=>{y.lights.delete(e.uuid)}}),[y,C]),u.createElement("group",h.default({ref:b},v),Array.from({length:f},((n,o)=>u.createElement("directionalLight",{key:o,castShadow:e,"shadow-bias":t,"shadow-mapSize":[r,r],intensity:g/f},u.createElement("orthographicCamera",{attach:"shadow-camera",args:[-a,a,a,-a,i,s]})))))}));class m{constructor(e,t,r=1024){this.renderer=e,this.res=r,this.scene=t,this.buffer1Active=!1,this.lights=[],this.meshes=[],this.object=null,this.clearColor=new c.Color,this.clearAlpha=0;const a={type:c.HalfFloatType,magFilter:c.NearestFilter,minFilter:c.NearestFilter};this.progressiveLightMap1=new c.WebGLRenderTarget(this.res,this.res,a),this.progressiveLightMap2=new c.WebGLRenderTarget(this.res,this.res,a),this.discardMat=new s.DiscardMaterial,this.targetMat=new c.MeshLambertMaterial({fog:!1}),this.previousShadowMap={value:this.progressiveLightMap1.texture},this.averagingWindow={value:100},this.targetMat.onBeforeCompile=e=>{e.vertexShader="varying vec2 vUv;\n"+e.vertexShader.slice(0,-1)+"vUv = uv; gl_Position = vec4((uv - 0.5) * 2.0, 1.0, 1.0); }";const t=e.fragmentShader.indexOf("void main() {");e.fragmentShader="varying vec2 vUv;\n"+e.fragmentShader.slice(0,t)+"uniform sampler2D previousShadowMap;\n\tuniform float averagingWindow;\n"+e.fragmentShader.slice(t-1,-1)+"\nvec3 texelOld = texture2D(previousShadowMap, vUv).rgb;\n gl_FragColor.rgb = mix(texelOld, gl_FragColor.rgb, 1.0/ averagingWindow);\n }",e.uniforms.previousShadowMap=this.previousShadowMap,e.uniforms.averagingWindow=this.averagingWindow}}clear(){this.renderer.getClearColor(this.clearColor),this.clearAlpha=this.renderer.getClearAlpha(),this.renderer.setClearColor("black",1),this.renderer.setRenderTarget(this.progressiveLightMap1),this.renderer.clear(),this.renderer.setRenderTarget(this.progressiveLightMap2),this.renderer.clear(),this.renderer.setRenderTarget(null),this.renderer.setClearColor(this.clearColor,this.clearAlpha),this.lights=[],this.meshes=[],this.scene.traverse((e=>{!function(e){return!!e.geometry}(e)?function(e){return e.isLight}(e)&&this.lights.push({object:e,intensity:e.intensity}):this.meshes.push({object:e,material:e.material})}))}prepare(){this.lights.forEach((e=>e.object.intensity=0)),this.meshes.forEach((e=>e.object.material=this.discardMat))}finish(){this.lights.forEach((e=>e.object.intensity=e.intensity)),this.meshes.forEach((e=>e.object.material=e.material))}configure(e){this.object=e}update(e,t=100){if(!this.object)return;this.averagingWindow.value=t,this.object.material=this.targetMat;const r=this.buffer1Active?this.progressiveLightMap1:this.progressiveLightMap2,a=this.buffer1Active?this.progressiveLightMap2:this.progressiveLightMap1,i=this.scene.background;this.scene.background=null,this.renderer.setRenderTarget(r),this.previousShadowMap.value=a.texture,this.buffer1Active=!this.buffer1Active,this.renderer.render(this.scene,e),this.renderer.setRenderTarget(null),this.scene.background=i}}exports.AccumulativeShadows=f,exports.RandomizedLight=g,exports.accumulativeContext=d;
|
|
@@ -4,6 +4,7 @@ import * as React from 'react';
|
|
|
4
4
|
import { extend, useThree, useFrame } from '@react-three/fiber';
|
|
5
5
|
import { shaderMaterial } from './shaderMaterial.js';
|
|
6
6
|
import { DiscardMaterial } from '../materials/DiscardMaterial.js';
|
|
7
|
+
import { version } from '../helpers/constants.js';
|
|
7
8
|
|
|
8
9
|
function isLight(object) {
|
|
9
10
|
return object.isLight;
|
|
@@ -11,9 +12,9 @@ function isLight(object) {
|
|
|
11
12
|
function isGeometry(object) {
|
|
12
13
|
return !!object.geometry;
|
|
13
14
|
}
|
|
14
|
-
const accumulativeContext =
|
|
15
|
-
const SoftShadowMaterial = shaderMaterial({
|
|
16
|
-
color: new THREE.Color(),
|
|
15
|
+
const accumulativeContext = /* @__PURE__ */React.createContext(null);
|
|
16
|
+
const SoftShadowMaterial = /* @__PURE__ */shaderMaterial({
|
|
17
|
+
color: /* @__PURE__ */new THREE.Color(),
|
|
17
18
|
blend: 2.0,
|
|
18
19
|
alphaTest: 0.75,
|
|
19
20
|
opacity: 0,
|
|
@@ -32,9 +33,9 @@ const SoftShadowMaterial = shaderMaterial({
|
|
|
32
33
|
vec4 sampledDiffuseColor = texture2D(map, vUv);
|
|
33
34
|
gl_FragColor = vec4(color * sampledDiffuseColor.r * blend, max(0.0, (1.0 - (sampledDiffuseColor.r + sampledDiffuseColor.g + sampledDiffuseColor.b) / alphaTest)) * opacity);
|
|
34
35
|
#include <tonemapping_fragment>
|
|
35
|
-
#include <${
|
|
36
|
+
#include <${version >= 154 ? 'colorspace_fragment' : 'encodings_fragment'}>
|
|
36
37
|
}`);
|
|
37
|
-
const AccumulativeShadows =
|
|
38
|
+
const AccumulativeShadows = /* @__PURE__ */React.forwardRef(({
|
|
38
39
|
children,
|
|
39
40
|
temporal,
|
|
40
41
|
frames = 40,
|
|
@@ -139,7 +140,7 @@ const AccumulativeShadows = /*#__PURE__*/React.forwardRef(({
|
|
|
139
140
|
map: plm.progressiveLightMap2.texture
|
|
140
141
|
})));
|
|
141
142
|
});
|
|
142
|
-
const RandomizedLight =
|
|
143
|
+
const RandomizedLight = /* @__PURE__ */React.forwardRef(({
|
|
143
144
|
castShadow = true,
|
|
144
145
|
bias = 0.001,
|
|
145
146
|
mapSize = 512,
|
|
@@ -150,7 +151,7 @@ const RandomizedLight = /*#__PURE__*/React.forwardRef(({
|
|
|
150
151
|
position = [0, 0, 0],
|
|
151
152
|
radius = 1,
|
|
152
153
|
amount = 8,
|
|
153
|
-
intensity =
|
|
154
|
+
intensity = version >= 155 ? Math.PI : 1,
|
|
154
155
|
ambient = 0.5,
|
|
155
156
|
...props
|
|
156
157
|
}, forwardRef) => {
|
package/core/ArcballControls.js
CHANGED
|
@@ -4,7 +4,7 @@ import * as React from 'react';
|
|
|
4
4
|
import { forwardRef, useMemo, useEffect } from 'react';
|
|
5
5
|
import { ArcballControls as ArcballControls$1 } from 'three-stdlib';
|
|
6
6
|
|
|
7
|
-
const ArcballControls =
|
|
7
|
+
const ArcballControls = /* @__PURE__ */forwardRef(({
|
|
8
8
|
camera,
|
|
9
9
|
makeDefault,
|
|
10
10
|
regress,
|
package/core/BBAnchor.js
CHANGED
|
@@ -3,8 +3,8 @@ import * as React from 'react';
|
|
|
3
3
|
import * as THREE from 'three';
|
|
4
4
|
import { useFrame } from '@react-three/fiber';
|
|
5
5
|
|
|
6
|
-
const boundingBox = new THREE.Box3();
|
|
7
|
-
const boundingBoxSize = new THREE.Vector3();
|
|
6
|
+
const boundingBox = /* @__PURE__ */new THREE.Box3();
|
|
7
|
+
const boundingBoxSize = /* @__PURE__ */new THREE.Vector3();
|
|
8
8
|
const BBAnchor = ({
|
|
9
9
|
anchor,
|
|
10
10
|
...props
|
package/core/Billboard.js
CHANGED
|
@@ -12,7 +12,7 @@ import mergeRefs from 'react-merge-refs';
|
|
|
12
12
|
* </Billboard>
|
|
13
13
|
* ```
|
|
14
14
|
*/
|
|
15
|
-
const Billboard =
|
|
15
|
+
const Billboard = /* @__PURE__ */React.forwardRef(function Billboard({
|
|
16
16
|
follow = true,
|
|
17
17
|
lockX = false,
|
|
18
18
|
lockY = false,
|
package/core/Bounds.js
CHANGED
|
@@ -4,7 +4,7 @@ import { useThree, useFrame } from '@react-three/fiber';
|
|
|
4
4
|
|
|
5
5
|
const isOrthographic = def => def && def.isOrthographicCamera;
|
|
6
6
|
const isBox3 = def => def && def.isBox3;
|
|
7
|
-
const context =
|
|
7
|
+
const context = /* @__PURE__ */React.createContext(null);
|
|
8
8
|
function Bounds({
|
|
9
9
|
children,
|
|
10
10
|
damping = 6,
|
package/core/CameraControls.js
CHANGED
|
@@ -5,7 +5,7 @@ import { forwardRef, useMemo, useEffect } from 'react';
|
|
|
5
5
|
import { extend, useThree, useFrame } from '@react-three/fiber';
|
|
6
6
|
import CameraControlsImpl from 'camera-controls';
|
|
7
7
|
|
|
8
|
-
const CameraControls =
|
|
8
|
+
const CameraControls = /* @__PURE__ */forwardRef((props, ref) => {
|
|
9
9
|
// useMemo is used here instead of useEffect, otherwise the useMemo below runs first and throws
|
|
10
10
|
useMemo(() => {
|
|
11
11
|
// to allow for tree shaking, we only import the subset of THREE that is used by camera-controls
|
package/core/CameraShake.js
CHANGED
|
@@ -2,7 +2,7 @@ import * as React from 'react';
|
|
|
2
2
|
import { useThree, useFrame } from '@react-three/fiber';
|
|
3
3
|
import { SimplexNoise } from 'three-stdlib';
|
|
4
4
|
|
|
5
|
-
const CameraShake =
|
|
5
|
+
const CameraShake = /* @__PURE__ */React.forwardRef(({
|
|
6
6
|
intensity = 1,
|
|
7
7
|
decay,
|
|
8
8
|
decayRate = 0.65,
|
package/core/CatmullRomLine.js
CHANGED
|
@@ -3,7 +3,7 @@ import * as React from 'react';
|
|
|
3
3
|
import { Vector3, CatmullRomCurve3, Color } from 'three';
|
|
4
4
|
import { Line } from './Line.js';
|
|
5
5
|
|
|
6
|
-
const CatmullRomLine =
|
|
6
|
+
const CatmullRomLine = /* @__PURE__ */React.forwardRef(function CatmullRomLine({
|
|
7
7
|
points,
|
|
8
8
|
closed = false,
|
|
9
9
|
curveType = 'centripetal',
|
package/core/Caustics.cjs.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@babel/runtime/helpers/extends"),r=require("three"),t=require("react"),n=require("@react-three/fiber"),o=require("./useFBO.cjs.js"),i=require("./useHelper.cjs.js"),a=require("./shaderMaterial.cjs.js"),l=require("./Edges.cjs.js"),c=require("three-stdlib");function s(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}function u(e){if(e&&e.__esModule)return e;var r=Object.create(null);return e&&Object.keys(e).forEach((function(t){if("default"!==t){var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,n.get?n:{enumerable:!0,get:function(){return e[t]}})}})),r.default=e,Object.freeze(r)}var d=s(e),m=u(r),p=u(t);function v(e=m.FrontSide){const r={value:new m.Matrix4};return Object.assign(new m.MeshNormalMaterial({side:e}),{viewMatrix:r,onBeforeCompile:e=>{e.uniforms.viewMatrix=r,e.fragmentShader="vec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {\n return normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );\n }\n"+e.fragmentShader.replace("#include <normal_fragment_maps>","#include <normal_fragment_maps>\n normal = inverseTransformDirection( normal, viewMatrix );\n")}})}const f=a.shaderMaterial({causticsTexture:null,causticsTextureB:null,color:new m.Color,lightProjMatrix:new m.Matrix4,lightViewMatrix:new m.Matrix4},"varying vec3 vWorldPosition; \n void main() {\n gl_Position = projectionMatrix * viewMatrix * modelMatrix * vec4(position, 1.);\n vec4 worldPosition = modelMatrix * vec4(position, 1.);\n vWorldPosition = worldPosition.xyz;\n }",`varying vec3 vWorldPosition;\n uniform vec3 color;\n uniform sampler2D causticsTexture; \n uniform sampler2D causticsTextureB; \n uniform mat4 lightProjMatrix;\n uniform mat4 lightViewMatrix;\n void main() {\n // Apply caustics \n vec4 lightSpacePos = lightProjMatrix * lightViewMatrix * vec4(vWorldPosition, 1.0);\n lightSpacePos.xyz /= lightSpacePos.w;\n lightSpacePos.xyz = lightSpacePos.xyz * 0.5 + 0.5; \n vec3 front = texture2D(causticsTexture, lightSpacePos.xy).rgb;\n vec3 back = texture2D(causticsTextureB, lightSpacePos.xy).rgb;\n gl_FragColor = vec4((front + back) * color, 1.0);\n #include <tonemapping_fragment>\n #include <${parseInt(m.REVISION.replace(/\D+/g,""))>=154?"colorspace_fragment":"encodings_fragment"}>\n }`),x=a.shaderMaterial({cameraMatrixWorld:new m.Matrix4,cameraProjectionMatrixInv:new m.Matrix4,normalTexture:null,depthTexture:null,lightDir:new m.Vector3(0,1,0),lightPlaneNormal:new m.Vector3(0,1,0),lightPlaneConstant:0,near:.1,far:100,modelMatrix:new m.Matrix4,worldRadius:1/40,ior:1.1,bounces:0,resolution:1024,size:10,intensity:.5},"\n varying vec2 vUv;\n void main() {\n vUv = uv;\n gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n }"," \n uniform mat4 cameraMatrixWorld;\n uniform mat4 cameraProjectionMatrixInv;\n uniform vec3 lightDir;\n uniform vec3 lightPlaneNormal;\n uniform float lightPlaneConstant;\n uniform float near;\n uniform float far;\n uniform float time;\n uniform float worldRadius;\n uniform float resolution;\n uniform float size;\n uniform float intensity;\n uniform float ior;\n precision highp isampler2D;\n precision highp usampler2D;\n uniform sampler2D normalTexture;\n uniform sampler2D depthTexture;\n uniform float bounces;\n varying vec2 vUv;\n vec3 WorldPosFromDepth(float depth, vec2 coord) {\n float z = depth * 2.0 - 1.0;\n vec4 clipSpacePosition = vec4(coord * 2.0 - 1.0, z, 1.0);\n vec4 viewSpacePosition = cameraProjectionMatrixInv * clipSpacePosition;\n // Perspective division\n viewSpacePosition /= viewSpacePosition.w;\n vec4 worldSpacePosition = cameraMatrixWorld * viewSpacePosition;\n return worldSpacePosition.xyz;\n } \n float sdPlane( vec3 p, vec3 n, float h ) {\n // n must be normalized\n return dot(p,n) + h;\n }\n float planeIntersect( vec3 ro, vec3 rd, vec4 p ) {\n return -(dot(ro,p.xyz)+p.w)/dot(rd,p.xyz);\n }\n vec3 totalInternalReflection(vec3 ro, vec3 rd, vec3 pos, vec3 normal, float ior, out vec3 rayOrigin, out vec3 rayDirection) {\n rayOrigin = ro;\n rayDirection = rd;\n rayDirection = refract(rayDirection, normal, 1.0 / ior);\n rayOrigin = pos + rayDirection * 0.1;\n return rayDirection;\n }\n void main() {\n // Each sample consists of random offset in the x and y direction\n float caustic = 0.0;\n float causticTexelSize = (1.0 / resolution) * size * 2.0;\n float texelsNeeded = worldRadius / causticTexelSize;\n float sampleRadius = texelsNeeded / resolution;\n float sum = 0.0;\n if (texture2D(depthTexture, vUv).x == 1.0) {\n gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0);\n return;\n }\n vec2 offset1 = vec2(-0.5, -0.5);//vec2(rand() - 0.5, rand() - 0.5);\n vec2 offset2 = vec2(-0.5, 0.5);//vec2(rand() - 0.5, rand() - 0.5);\n vec2 offset3 = vec2(0.5, 0.5);//vec2(rand() - 0.5, rand() - 0.5);\n vec2 offset4 = vec2(0.5, -0.5);//vec2(rand() - 0.5, rand() - 0.5);\n vec2 uv1 = vUv + offset1 * sampleRadius;\n vec2 uv2 = vUv + offset2 * sampleRadius;\n vec2 uv3 = vUv + offset3 * sampleRadius;\n vec2 uv4 = vUv + offset4 * sampleRadius;\n vec3 normal1 = texture2D(normalTexture, uv1, -10.0).rgb * 2.0 - 1.0;\n vec3 normal2 = texture2D(normalTexture, uv2, -10.0).rgb * 2.0 - 1.0;\n vec3 normal3 = texture2D(normalTexture, uv3, -10.0).rgb * 2.0 - 1.0;\n vec3 normal4 = texture2D(normalTexture, uv4, -10.0).rgb * 2.0 - 1.0;\n float depth1 = texture2D(depthTexture, uv1, -10.0).x;\n float depth2 = texture2D(depthTexture, uv2, -10.0).x;\n float depth3 = texture2D(depthTexture, uv3, -10.0).x;\n float depth4 = texture2D(depthTexture, uv4, -10.0).x;\n // Sanity check the depths\n if (depth1 == 1.0 || depth2 == 1.0 || depth3 == 1.0 || depth4 == 1.0) {\n gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0);\n return;\n }\n vec3 pos1 = WorldPosFromDepth(depth1, uv1);\n vec3 pos2 = WorldPosFromDepth(depth2, uv2);\n vec3 pos3 = WorldPosFromDepth(depth3, uv3);\n vec3 pos4 = WorldPosFromDepth(depth4, uv4);\n vec3 originPos1 = WorldPosFromDepth(0.0, uv1);\n vec3 originPos2 = WorldPosFromDepth(0.0, uv2);\n vec3 originPos3 = WorldPosFromDepth(0.0, uv3);\n vec3 originPos4 = WorldPosFromDepth(0.0, uv4);\n vec3 endPos1, endPos2, endPos3, endPos4;\n vec3 endDir1, endDir2, endDir3, endDir4;\n totalInternalReflection(originPos1, lightDir, pos1, normal1, ior, endPos1, endDir1);\n totalInternalReflection(originPos2, lightDir, pos2, normal2, ior, endPos2, endDir2);\n totalInternalReflection(originPos3, lightDir, pos3, normal3, ior, endPos3, endDir3);\n totalInternalReflection(originPos4, lightDir, pos4, normal4, ior, endPos4, endDir4);\n float lightPosArea = length(cross(originPos2 - originPos1, originPos3 - originPos1)) + length(cross(originPos3 - originPos1, originPos4 - originPos1));\n float t1 = planeIntersect(endPos1, endDir1, vec4(lightPlaneNormal, lightPlaneConstant));\n float t2 = planeIntersect(endPos2, endDir2, vec4(lightPlaneNormal, lightPlaneConstant));\n float t3 = planeIntersect(endPos3, endDir3, vec4(lightPlaneNormal, lightPlaneConstant));\n float t4 = planeIntersect(endPos4, endDir4, vec4(lightPlaneNormal, lightPlaneConstant));\n vec3 finalPos1 = endPos1 + endDir1 * t1;\n vec3 finalPos2 = endPos2 + endDir2 * t2;\n vec3 finalPos3 = endPos3 + endDir3 * t3;\n vec3 finalPos4 = endPos4 + endDir4 * t4;\n float finalArea = length(cross(finalPos2 - finalPos1, finalPos3 - finalPos1)) + length(cross(finalPos3 - finalPos1, finalPos4 - finalPos1));\n caustic += intensity * (lightPosArea / finalArea);\n // Calculate the area of the triangle in light spaces\n gl_FragColor = vec4(vec3(max(caustic, 0.0)), 1.0);\n }"),h={depth:!0,minFilter:m.LinearFilter,magFilter:m.LinearFilter,type:m.UnsignedByteType},g={minFilter:m.LinearMipmapLinearFilter,magFilter:m.LinearFilter,type:m.FloatType,generateMipmaps:!0},P=p.forwardRef((({debug:e,children:r,frames:t=1,ior:a=1.1,color:s="white",causticsOnly:u=!1,backside:P=!1,backsideIOR:y=1.1,worldRadius:M=.3125,intensity:D=.05,resolution:w=2024,lightSource:T=[5,5,5],...S},b)=>{n.extend({CausticsProjectionMaterial:f});const j=p.useRef(null),F=p.useRef(null),z=p.useRef(null),R=p.useRef(null),W=n.useThree((e=>e.gl)),I=i.useHelper(e&&F,m.CameraHelper),O=o.useFBO(w,w,h),C=o.useFBO(w,w,h),V=o.useFBO(w,w,g),_=o.useFBO(w,w,g),[B]=p.useState((()=>v())),[E]=p.useState((()=>v(m.BackSide))),[A]=p.useState((()=>new x)),[N]=p.useState((()=>new c.FullScreenQuad(A)));p.useLayoutEffect((()=>{j.current.updateWorldMatrix(!1,!0)}));let k=0;const q=new m.Vector3,U=new m.Frustum,L=new m.Matrix4,H=new m.Plane,G=new m.Vector3,Q=new m.Vector3,$=new m.Box3,J=new m.Vector3,K=[],X=[],Y=[],Z=[],ee=new m.Vector3;for(let e=0;e<8;e++)K.push(new m.Vector3),X.push(new m.Vector3),Y.push(new m.Vector3),Z.push(new m.Vector3);return n.useFrame((()=>{if(t===1/0||k++<t){var r,n;Array.isArray(T)?G.fromArray(T).normalize():G.copy(j.current.worldToLocal(T.current.getWorldPosition(q)).normalize()),Q.copy(G).multiplyScalar(-1),null==(r=z.current.parent)||r.matrixWorld.identity(),$.setFromObject(z.current,!0),K[0].set($.min.x,$.min.y,$.min.z),K[1].set($.min.x,$.min.y,$.max.z),K[2].set($.min.x,$.max.y,$.min.z),K[3].set($.min.x,$.max.y,$.max.z),K[4].set($.max.x,$.min.y,$.min.z),K[5].set($.max.x,$.min.y,$.max.z),K[6].set($.max.x,$.max.y,$.min.z),K[7].set($.max.x,$.max.y,$.max.z);for(let e=0;e<8;e++)X[e].copy(K[e]);$.getCenter(J),K.map((e=>e.sub(J)));const t=H.set(Q,0);K.map(((e,r)=>t.projectPoint(e,Y[r])));const o=Y.reduce(((e,r)=>e.add(r)),q.set(0,0,0)).divideScalar(Y.length),i=Y.map((e=>e.distanceTo(o))).reduce(((e,r)=>Math.max(e,r))),l=K.map((e=>e.dot(G))).reduce(((e,r)=>Math.max(e,r)));F.current.position.copy(ee.copy(G).multiplyScalar(l).add(J)),F.current.lookAt(z.current.localToWorld(J));const c=L.lookAt(F.current.position,J,q.set(0,1,0));F.current.left=-i,F.current.right=i,F.current.top=i,F.current.bottom=-i;const s=q.set(0,i,0).applyMatrix4(c),d=(F.current.position.y+s.y)/G.y;F.current.near=.1,F.current.far=d,F.current.updateProjectionMatrix(),F.current.updateMatrixWorld();const m=X.map(((e,r)=>e.add(Z[r].copy(G).multiplyScalar(-e.y/G.y)))),p=m.reduce(((e,r)=>e.add(r)),q.set(0,0,0)).divideScalar(m.length),v=2*m.map((e=>Math.hypot(e.x-p.x,e.z-p.z))).reduce(((e,r)=>Math.max(e,r)));R.current.scale.setScalar(v),R.current.position.copy(p),e&&(null==(n=I.current)||n.update()),E.viewMatrix.value=B.viewMatrix.value=F.current.matrixWorldInverse;const f=U.setFromProjectionMatrix(L.multiplyMatrices(F.current.projectionMatrix,F.current.matrixWorldInverse)).planes[4];A.cameraMatrixWorld=F.current.matrixWorld,A.cameraProjectionMatrixInv=F.current.projectionMatrixInverse,A.lightDir=Q,A.lightPlaneNormal=f.normal,A.lightPlaneConstant=f.constant,A.near=F.current.near,A.far=F.current.far,A.resolution=w,A.size=i,A.intensity=D,A.worldRadius=M,z.current.visible=!0,W.setRenderTarget(O),W.clear(),z.current.overrideMaterial=B,W.render(z.current,F.current),W.setRenderTarget(C),W.clear(),P&&(z.current.overrideMaterial=E,W.render(z.current,F.current)),z.current.overrideMaterial=null,A.ior=a,R.current.material.lightProjMatrix=F.current.projectionMatrix,R.current.material.lightViewMatrix=F.current.matrixWorldInverse,A.normalTexture=O.texture,A.depthTexture=O.depthTexture,W.setRenderTarget(V),W.clear(),N.render(W),A.ior=y,A.normalTexture=C.texture,A.depthTexture=C.depthTexture,W.setRenderTarget(_),W.clear(),P&&N.render(W),W.setRenderTarget(null),u&&(z.current.visible=!1)}})),p.useImperativeHandle(b,(()=>j.current),[]),p.createElement("group",d.default({ref:j},S),p.createElement("scene",{ref:z},p.createElement("orthographicCamera",{ref:F,up:[0,1,0]}),r),p.createElement("mesh",{renderOrder:2,ref:R,"rotation-x":-Math.PI/2},p.createElement("planeGeometry",null),p.createElement("causticsProjectionMaterial",{transparent:!0,color:s,causticsTexture:V.texture,causticsTextureB:_.texture,blending:m.CustomBlending,blendSrc:m.OneFactor,blendDst:m.SrcAlphaFactor,depthWrite:!1}),e&&p.createElement(l.Edges,null,p.createElement("lineBasicMaterial",{color:"#ffff00",toneMapped:!1}))))}));exports.Caustics=P;
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@babel/runtime/helpers/extends"),r=require("three"),t=require("react"),n=require("@react-three/fiber"),o=require("./useFBO.cjs.js"),i=require("./useHelper.cjs.js"),a=require("./shaderMaterial.cjs.js"),l=require("./Edges.cjs.js"),c=require("three-stdlib"),s=require("../helpers/constants.cjs.js");function u(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}function d(e){if(e&&e.__esModule)return e;var r=Object.create(null);return e&&Object.keys(e).forEach((function(t){if("default"!==t){var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,n.get?n:{enumerable:!0,get:function(){return e[t]}})}})),r.default=e,Object.freeze(r)}var m=u(e),p=d(r),v=d(t);function f(e=p.FrontSide){const r={value:new p.Matrix4};return Object.assign(new p.MeshNormalMaterial({side:e}),{viewMatrix:r,onBeforeCompile:e=>{e.uniforms.viewMatrix=r,e.fragmentShader="vec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {\n return normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );\n }\n"+e.fragmentShader.replace("#include <normal_fragment_maps>","#include <normal_fragment_maps>\n normal = inverseTransformDirection( normal, viewMatrix );\n")}})}const x=a.shaderMaterial({causticsTexture:null,causticsTextureB:null,color:new p.Color,lightProjMatrix:new p.Matrix4,lightViewMatrix:new p.Matrix4},"varying vec3 vWorldPosition; \n void main() {\n gl_Position = projectionMatrix * viewMatrix * modelMatrix * vec4(position, 1.);\n vec4 worldPosition = modelMatrix * vec4(position, 1.);\n vWorldPosition = worldPosition.xyz;\n }",`varying vec3 vWorldPosition;\n uniform vec3 color;\n uniform sampler2D causticsTexture; \n uniform sampler2D causticsTextureB; \n uniform mat4 lightProjMatrix;\n uniform mat4 lightViewMatrix;\n void main() {\n // Apply caustics \n vec4 lightSpacePos = lightProjMatrix * lightViewMatrix * vec4(vWorldPosition, 1.0);\n lightSpacePos.xyz /= lightSpacePos.w;\n lightSpacePos.xyz = lightSpacePos.xyz * 0.5 + 0.5; \n vec3 front = texture2D(causticsTexture, lightSpacePos.xy).rgb;\n vec3 back = texture2D(causticsTextureB, lightSpacePos.xy).rgb;\n gl_FragColor = vec4((front + back) * color, 1.0);\n #include <tonemapping_fragment>\n #include <${s.version>=154?"colorspace_fragment":"encodings_fragment"}>\n }`),h=a.shaderMaterial({cameraMatrixWorld:new p.Matrix4,cameraProjectionMatrixInv:new p.Matrix4,normalTexture:null,depthTexture:null,lightDir:new p.Vector3(0,1,0),lightPlaneNormal:new p.Vector3(0,1,0),lightPlaneConstant:0,near:.1,far:100,modelMatrix:new p.Matrix4,worldRadius:1/40,ior:1.1,bounces:0,resolution:1024,size:10,intensity:.5},"\n varying vec2 vUv;\n void main() {\n vUv = uv;\n gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n }"," \n uniform mat4 cameraMatrixWorld;\n uniform mat4 cameraProjectionMatrixInv;\n uniform vec3 lightDir;\n uniform vec3 lightPlaneNormal;\n uniform float lightPlaneConstant;\n uniform float near;\n uniform float far;\n uniform float time;\n uniform float worldRadius;\n uniform float resolution;\n uniform float size;\n uniform float intensity;\n uniform float ior;\n precision highp isampler2D;\n precision highp usampler2D;\n uniform sampler2D normalTexture;\n uniform sampler2D depthTexture;\n uniform float bounces;\n varying vec2 vUv;\n vec3 WorldPosFromDepth(float depth, vec2 coord) {\n float z = depth * 2.0 - 1.0;\n vec4 clipSpacePosition = vec4(coord * 2.0 - 1.0, z, 1.0);\n vec4 viewSpacePosition = cameraProjectionMatrixInv * clipSpacePosition;\n // Perspective division\n viewSpacePosition /= viewSpacePosition.w;\n vec4 worldSpacePosition = cameraMatrixWorld * viewSpacePosition;\n return worldSpacePosition.xyz;\n } \n float sdPlane( vec3 p, vec3 n, float h ) {\n // n must be normalized\n return dot(p,n) + h;\n }\n float planeIntersect( vec3 ro, vec3 rd, vec4 p ) {\n return -(dot(ro,p.xyz)+p.w)/dot(rd,p.xyz);\n }\n vec3 totalInternalReflection(vec3 ro, vec3 rd, vec3 pos, vec3 normal, float ior, out vec3 rayOrigin, out vec3 rayDirection) {\n rayOrigin = ro;\n rayDirection = rd;\n rayDirection = refract(rayDirection, normal, 1.0 / ior);\n rayOrigin = pos + rayDirection * 0.1;\n return rayDirection;\n }\n void main() {\n // Each sample consists of random offset in the x and y direction\n float caustic = 0.0;\n float causticTexelSize = (1.0 / resolution) * size * 2.0;\n float texelsNeeded = worldRadius / causticTexelSize;\n float sampleRadius = texelsNeeded / resolution;\n float sum = 0.0;\n if (texture2D(depthTexture, vUv).x == 1.0) {\n gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0);\n return;\n }\n vec2 offset1 = vec2(-0.5, -0.5);//vec2(rand() - 0.5, rand() - 0.5);\n vec2 offset2 = vec2(-0.5, 0.5);//vec2(rand() - 0.5, rand() - 0.5);\n vec2 offset3 = vec2(0.5, 0.5);//vec2(rand() - 0.5, rand() - 0.5);\n vec2 offset4 = vec2(0.5, -0.5);//vec2(rand() - 0.5, rand() - 0.5);\n vec2 uv1 = vUv + offset1 * sampleRadius;\n vec2 uv2 = vUv + offset2 * sampleRadius;\n vec2 uv3 = vUv + offset3 * sampleRadius;\n vec2 uv4 = vUv + offset4 * sampleRadius;\n vec3 normal1 = texture2D(normalTexture, uv1, -10.0).rgb * 2.0 - 1.0;\n vec3 normal2 = texture2D(normalTexture, uv2, -10.0).rgb * 2.0 - 1.0;\n vec3 normal3 = texture2D(normalTexture, uv3, -10.0).rgb * 2.0 - 1.0;\n vec3 normal4 = texture2D(normalTexture, uv4, -10.0).rgb * 2.0 - 1.0;\n float depth1 = texture2D(depthTexture, uv1, -10.0).x;\n float depth2 = texture2D(depthTexture, uv2, -10.0).x;\n float depth3 = texture2D(depthTexture, uv3, -10.0).x;\n float depth4 = texture2D(depthTexture, uv4, -10.0).x;\n // Sanity check the depths\n if (depth1 == 1.0 || depth2 == 1.0 || depth3 == 1.0 || depth4 == 1.0) {\n gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0);\n return;\n }\n vec3 pos1 = WorldPosFromDepth(depth1, uv1);\n vec3 pos2 = WorldPosFromDepth(depth2, uv2);\n vec3 pos3 = WorldPosFromDepth(depth3, uv3);\n vec3 pos4 = WorldPosFromDepth(depth4, uv4);\n vec3 originPos1 = WorldPosFromDepth(0.0, uv1);\n vec3 originPos2 = WorldPosFromDepth(0.0, uv2);\n vec3 originPos3 = WorldPosFromDepth(0.0, uv3);\n vec3 originPos4 = WorldPosFromDepth(0.0, uv4);\n vec3 endPos1, endPos2, endPos3, endPos4;\n vec3 endDir1, endDir2, endDir3, endDir4;\n totalInternalReflection(originPos1, lightDir, pos1, normal1, ior, endPos1, endDir1);\n totalInternalReflection(originPos2, lightDir, pos2, normal2, ior, endPos2, endDir2);\n totalInternalReflection(originPos3, lightDir, pos3, normal3, ior, endPos3, endDir3);\n totalInternalReflection(originPos4, lightDir, pos4, normal4, ior, endPos4, endDir4);\n float lightPosArea = length(cross(originPos2 - originPos1, originPos3 - originPos1)) + length(cross(originPos3 - originPos1, originPos4 - originPos1));\n float t1 = planeIntersect(endPos1, endDir1, vec4(lightPlaneNormal, lightPlaneConstant));\n float t2 = planeIntersect(endPos2, endDir2, vec4(lightPlaneNormal, lightPlaneConstant));\n float t3 = planeIntersect(endPos3, endDir3, vec4(lightPlaneNormal, lightPlaneConstant));\n float t4 = planeIntersect(endPos4, endDir4, vec4(lightPlaneNormal, lightPlaneConstant));\n vec3 finalPos1 = endPos1 + endDir1 * t1;\n vec3 finalPos2 = endPos2 + endDir2 * t2;\n vec3 finalPos3 = endPos3 + endDir3 * t3;\n vec3 finalPos4 = endPos4 + endDir4 * t4;\n float finalArea = length(cross(finalPos2 - finalPos1, finalPos3 - finalPos1)) + length(cross(finalPos3 - finalPos1, finalPos4 - finalPos1));\n caustic += intensity * (lightPosArea / finalArea);\n // Calculate the area of the triangle in light spaces\n gl_FragColor = vec4(vec3(max(caustic, 0.0)), 1.0);\n }"),g={depth:!0,minFilter:p.LinearFilter,magFilter:p.LinearFilter,type:p.UnsignedByteType},P={minFilter:p.LinearMipmapLinearFilter,magFilter:p.LinearFilter,type:p.FloatType,generateMipmaps:!0},y=v.forwardRef((({debug:e,children:r,frames:t=1,ior:a=1.1,color:s="white",causticsOnly:u=!1,backside:d=!1,backsideIOR:y=1.1,worldRadius:M=.3125,intensity:D=.05,resolution:w=2024,lightSource:T=[5,5,5],...j},S)=>{n.extend({CausticsProjectionMaterial:x});const b=v.useRef(null),F=v.useRef(null),z=v.useRef(null),W=v.useRef(null),R=n.useThree((e=>e.gl)),I=i.useHelper(e&&F,p.CameraHelper),O=o.useFBO(w,w,g),C=o.useFBO(w,w,g),_=o.useFBO(w,w,P),V=o.useFBO(w,w,P),[B]=v.useState((()=>f())),[E]=v.useState((()=>f(p.BackSide))),[A]=v.useState((()=>new h)),[q]=v.useState((()=>new c.FullScreenQuad(A)));v.useLayoutEffect((()=>{b.current.updateWorldMatrix(!1,!0)}));let N=0;const k=new p.Vector3,U=new p.Frustum,L=new p.Matrix4,H=new p.Plane,G=new p.Vector3,Q=new p.Vector3,$=new p.Box3,J=new p.Vector3,K=[],X=[],Y=[],Z=[],ee=new p.Vector3;for(let e=0;e<8;e++)K.push(new p.Vector3),X.push(new p.Vector3),Y.push(new p.Vector3),Z.push(new p.Vector3);return n.useFrame((()=>{if(t===1/0||N++<t){var r,n;Array.isArray(T)?G.fromArray(T).normalize():G.copy(b.current.worldToLocal(T.current.getWorldPosition(k)).normalize()),Q.copy(G).multiplyScalar(-1),null==(r=z.current.parent)||r.matrixWorld.identity(),$.setFromObject(z.current,!0),K[0].set($.min.x,$.min.y,$.min.z),K[1].set($.min.x,$.min.y,$.max.z),K[2].set($.min.x,$.max.y,$.min.z),K[3].set($.min.x,$.max.y,$.max.z),K[4].set($.max.x,$.min.y,$.min.z),K[5].set($.max.x,$.min.y,$.max.z),K[6].set($.max.x,$.max.y,$.min.z),K[7].set($.max.x,$.max.y,$.max.z);for(let e=0;e<8;e++)X[e].copy(K[e]);$.getCenter(J),K.map((e=>e.sub(J)));const t=H.set(Q,0);K.map(((e,r)=>t.projectPoint(e,Y[r])));const o=Y.reduce(((e,r)=>e.add(r)),k.set(0,0,0)).divideScalar(Y.length),i=Y.map((e=>e.distanceTo(o))).reduce(((e,r)=>Math.max(e,r))),l=K.map((e=>e.dot(G))).reduce(((e,r)=>Math.max(e,r)));F.current.position.copy(ee.copy(G).multiplyScalar(l).add(J)),F.current.lookAt(z.current.localToWorld(J));const c=L.lookAt(F.current.position,J,k.set(0,1,0));F.current.left=-i,F.current.right=i,F.current.top=i,F.current.bottom=-i;const s=k.set(0,i,0).applyMatrix4(c),m=(F.current.position.y+s.y)/G.y;F.current.near=.1,F.current.far=m,F.current.updateProjectionMatrix(),F.current.updateMatrixWorld();const p=X.map(((e,r)=>e.add(Z[r].copy(G).multiplyScalar(-e.y/G.y)))),v=p.reduce(((e,r)=>e.add(r)),k.set(0,0,0)).divideScalar(p.length),f=2*p.map((e=>Math.hypot(e.x-v.x,e.z-v.z))).reduce(((e,r)=>Math.max(e,r)));W.current.scale.setScalar(f),W.current.position.copy(v),e&&(null==(n=I.current)||n.update()),E.viewMatrix.value=B.viewMatrix.value=F.current.matrixWorldInverse;const x=U.setFromProjectionMatrix(L.multiplyMatrices(F.current.projectionMatrix,F.current.matrixWorldInverse)).planes[4];A.cameraMatrixWorld=F.current.matrixWorld,A.cameraProjectionMatrixInv=F.current.projectionMatrixInverse,A.lightDir=Q,A.lightPlaneNormal=x.normal,A.lightPlaneConstant=x.constant,A.near=F.current.near,A.far=F.current.far,A.resolution=w,A.size=i,A.intensity=D,A.worldRadius=M,z.current.visible=!0,R.setRenderTarget(O),R.clear(),z.current.overrideMaterial=B,R.render(z.current,F.current),R.setRenderTarget(C),R.clear(),d&&(z.current.overrideMaterial=E,R.render(z.current,F.current)),z.current.overrideMaterial=null,A.ior=a,W.current.material.lightProjMatrix=F.current.projectionMatrix,W.current.material.lightViewMatrix=F.current.matrixWorldInverse,A.normalTexture=O.texture,A.depthTexture=O.depthTexture,R.setRenderTarget(_),R.clear(),q.render(R),A.ior=y,A.normalTexture=C.texture,A.depthTexture=C.depthTexture,R.setRenderTarget(V),R.clear(),d&&q.render(R),R.setRenderTarget(null),u&&(z.current.visible=!1)}})),v.useImperativeHandle(S,(()=>b.current),[]),v.createElement("group",m.default({ref:b},j),v.createElement("scene",{ref:z},v.createElement("orthographicCamera",{ref:F,up:[0,1,0]}),r),v.createElement("mesh",{renderOrder:2,ref:W,"rotation-x":-Math.PI/2},v.createElement("planeGeometry",null),v.createElement("causticsProjectionMaterial",{transparent:!0,color:s,causticsTexture:_.texture,causticsTextureB:V.texture,blending:p.CustomBlending,blendSrc:p.OneFactor,blendDst:p.SrcAlphaFactor,depthWrite:!1}),e&&v.createElement(l.Edges,null,v.createElement("lineBasicMaterial",{color:"#ffff00",toneMapped:!1}))))}));exports.Caustics=y;
|
package/core/Caustics.js
CHANGED
|
@@ -7,6 +7,7 @@ import { useHelper } from './useHelper.js';
|
|
|
7
7
|
import { shaderMaterial } from './shaderMaterial.js';
|
|
8
8
|
import { Edges } from './Edges.js';
|
|
9
9
|
import { FullScreenQuad } from 'three-stdlib';
|
|
10
|
+
import { version } from '../helpers/constants.js';
|
|
10
11
|
|
|
11
12
|
function createNormalMaterial(side = THREE.FrontSide) {
|
|
12
13
|
const viewMatrix = {
|
|
@@ -25,12 +26,12 @@ function createNormalMaterial(side = THREE.FrontSide) {
|
|
|
25
26
|
}
|
|
26
27
|
});
|
|
27
28
|
}
|
|
28
|
-
const CausticsProjectionMaterial = shaderMaterial({
|
|
29
|
+
const CausticsProjectionMaterial = /* @__PURE__ */shaderMaterial({
|
|
29
30
|
causticsTexture: null,
|
|
30
31
|
causticsTextureB: null,
|
|
31
|
-
color: new THREE.Color(),
|
|
32
|
-
lightProjMatrix: new THREE.Matrix4(),
|
|
33
|
-
lightViewMatrix: new THREE.Matrix4()
|
|
32
|
+
color: /* @__PURE__ */new THREE.Color(),
|
|
33
|
+
lightProjMatrix: /* @__PURE__ */new THREE.Matrix4(),
|
|
34
|
+
lightViewMatrix: /* @__PURE__ */new THREE.Matrix4()
|
|
34
35
|
}, `varying vec3 vWorldPosition;
|
|
35
36
|
void main() {
|
|
36
37
|
gl_Position = projectionMatrix * viewMatrix * modelMatrix * vec4(position, 1.);
|
|
@@ -51,19 +52,19 @@ const CausticsProjectionMaterial = shaderMaterial({
|
|
|
51
52
|
vec3 back = texture2D(causticsTextureB, lightSpacePos.xy).rgb;
|
|
52
53
|
gl_FragColor = vec4((front + back) * color, 1.0);
|
|
53
54
|
#include <tonemapping_fragment>
|
|
54
|
-
#include <${
|
|
55
|
+
#include <${version >= 154 ? 'colorspace_fragment' : 'encodings_fragment'}>
|
|
55
56
|
}`);
|
|
56
|
-
const CausticsMaterial = shaderMaterial({
|
|
57
|
-
cameraMatrixWorld: new THREE.Matrix4(),
|
|
58
|
-
cameraProjectionMatrixInv: new THREE.Matrix4(),
|
|
57
|
+
const CausticsMaterial = /* @__PURE__ */shaderMaterial({
|
|
58
|
+
cameraMatrixWorld: /* @__PURE__ */new THREE.Matrix4(),
|
|
59
|
+
cameraProjectionMatrixInv: /* @__PURE__ */new THREE.Matrix4(),
|
|
59
60
|
normalTexture: null,
|
|
60
61
|
depthTexture: null,
|
|
61
|
-
lightDir: new THREE.Vector3(0, 1, 0),
|
|
62
|
-
lightPlaneNormal: new THREE.Vector3(0, 1, 0),
|
|
62
|
+
lightDir: /* @__PURE__ */new THREE.Vector3(0, 1, 0),
|
|
63
|
+
lightPlaneNormal: /* @__PURE__ */new THREE.Vector3(0, 1, 0),
|
|
63
64
|
lightPlaneConstant: 0,
|
|
64
65
|
near: 0.1,
|
|
65
66
|
far: 100,
|
|
66
|
-
modelMatrix: new THREE.Matrix4(),
|
|
67
|
+
modelMatrix: /* @__PURE__ */new THREE.Matrix4(),
|
|
67
68
|
worldRadius: 1 / 40,
|
|
68
69
|
ior: 1.1,
|
|
69
70
|
bounces: 0,
|
|
@@ -190,7 +191,7 @@ const CAUSTICPROPS = {
|
|
|
190
191
|
type: THREE.FloatType,
|
|
191
192
|
generateMipmaps: true
|
|
192
193
|
};
|
|
193
|
-
const Caustics =
|
|
194
|
+
const Caustics = /* @__PURE__ */React.forwardRef(({
|
|
194
195
|
debug,
|
|
195
196
|
children,
|
|
196
197
|
frames = 1,
|
package/core/Center.js
CHANGED
|
@@ -2,7 +2,7 @@ import _extends from '@babel/runtime/helpers/esm/extends';
|
|
|
2
2
|
import { Box3, Vector3, Sphere } from 'three';
|
|
3
3
|
import * as React from 'react';
|
|
4
4
|
|
|
5
|
-
const Center =
|
|
5
|
+
const Center = /* @__PURE__ */React.forwardRef(function Center({
|
|
6
6
|
children,
|
|
7
7
|
disable,
|
|
8
8
|
disableX,
|
package/core/Clone.js
CHANGED
package/core/Cloud.js
CHANGED
|
@@ -6,14 +6,14 @@ import { useTexture } from './useTexture.js';
|
|
|
6
6
|
import { v4 } from 'uuid';
|
|
7
7
|
|
|
8
8
|
const CLOUD_URL = 'https://rawcdn.githack.com/pmndrs/drei-assets/9225a9f1fbd449d9411125c2f419b843d0308c9f/cloud.png';
|
|
9
|
-
const parentMatrix =
|
|
10
|
-
const translation =
|
|
11
|
-
const rotation =
|
|
12
|
-
const cpos =
|
|
13
|
-
const cquat =
|
|
14
|
-
const scale =
|
|
15
|
-
const context =
|
|
16
|
-
const Clouds =
|
|
9
|
+
const parentMatrix = /* @__PURE__ */new Matrix4();
|
|
10
|
+
const translation = /* @__PURE__ */new Vector3();
|
|
11
|
+
const rotation = /* @__PURE__ */new Quaternion();
|
|
12
|
+
const cpos = /* @__PURE__ */new Vector3();
|
|
13
|
+
const cquat = /* @__PURE__ */new Quaternion();
|
|
14
|
+
const scale = /* @__PURE__ */new Vector3();
|
|
15
|
+
const context = /* @__PURE__ */React.createContext(null);
|
|
16
|
+
const Clouds = /* @__PURE__ */React.forwardRef(({
|
|
17
17
|
children,
|
|
18
18
|
material = MeshLambertMaterial,
|
|
19
19
|
texture = CLOUD_URL,
|
|
@@ -121,7 +121,7 @@ const Clouds = /*#__PURE__*/React.forwardRef(({
|
|
|
121
121
|
depthWrite: false
|
|
122
122
|
}))));
|
|
123
123
|
});
|
|
124
|
-
const CloudInstance =
|
|
124
|
+
const CloudInstance = /* @__PURE__ */React.forwardRef(({
|
|
125
125
|
opacity = 1,
|
|
126
126
|
speed = 0,
|
|
127
127
|
bounds = [5, 1, 1],
|
|
@@ -202,7 +202,7 @@ const CloudInstance = /*#__PURE__*/React.forwardRef(({
|
|
|
202
202
|
ref: ref
|
|
203
203
|
}, props));
|
|
204
204
|
});
|
|
205
|
-
const Cloud =
|
|
205
|
+
const Cloud = /* @__PURE__ */React.forwardRef((props, fref) => {
|
|
206
206
|
const parent = React.useContext(context);
|
|
207
207
|
if (parent) return /*#__PURE__*/React.createElement(CloudInstance, _extends({
|
|
208
208
|
ref: fref
|
package/core/ContactShadows.js
CHANGED
|
@@ -4,7 +4,7 @@ import * as THREE from 'three';
|
|
|
4
4
|
import { useThree, useFrame } from '@react-three/fiber';
|
|
5
5
|
import { HorizontalBlurShader, VerticalBlurShader } from 'three-stdlib';
|
|
6
6
|
|
|
7
|
-
const ContactShadows =
|
|
7
|
+
const ContactShadows = /* @__PURE__ */React.forwardRef(({
|
|
8
8
|
scale = 10,
|
|
9
9
|
frames = Infinity,
|
|
10
10
|
opacity = 1,
|
package/core/CubicBezierLine.js
CHANGED
|
@@ -3,7 +3,7 @@ import * as React from 'react';
|
|
|
3
3
|
import { Vector3, CubicBezierCurve3 } from 'three';
|
|
4
4
|
import { Line } from './Line.js';
|
|
5
5
|
|
|
6
|
-
const CubicBezierLine =
|
|
6
|
+
const CubicBezierLine = /* @__PURE__ */React.forwardRef(function CubicBezierLine({
|
|
7
7
|
start,
|
|
8
8
|
end,
|
|
9
9
|
midA,
|
package/core/CurveModifier.js
CHANGED
|
@@ -3,7 +3,7 @@ import * as THREE from 'three';
|
|
|
3
3
|
import { createPortal } from '@react-three/fiber';
|
|
4
4
|
import { Flow } from 'three-stdlib';
|
|
5
5
|
|
|
6
|
-
const CurveModifier =
|
|
6
|
+
const CurveModifier = /* @__PURE__ */React.forwardRef(({
|
|
7
7
|
children,
|
|
8
8
|
curve
|
|
9
9
|
}, ref) => {
|
package/core/Decal.js
CHANGED
|
@@ -16,7 +16,7 @@ function vecToArray(vec = [0, 0, 0]) {
|
|
|
16
16
|
return [vec, vec, vec];
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
|
-
const Decal =
|
|
19
|
+
const Decal = /* @__PURE__ */React.forwardRef(function Decal({
|
|
20
20
|
debug,
|
|
21
21
|
depthTest = false,
|
|
22
22
|
polygonOffsetFactor = -10,
|
package/core/Detailed.js
CHANGED
|
@@ -3,7 +3,7 @@ import * as React from 'react';
|
|
|
3
3
|
import { useFrame } from '@react-three/fiber';
|
|
4
4
|
import mergeRefs from 'react-merge-refs';
|
|
5
5
|
|
|
6
|
-
const Detailed =
|
|
6
|
+
const Detailed = /* @__PURE__ */React.forwardRef(({
|
|
7
7
|
children,
|
|
8
8
|
hysteresis = 0,
|
|
9
9
|
distances,
|
|
@@ -3,7 +3,7 @@ import { useThree, useFrame } from '@react-three/fiber';
|
|
|
3
3
|
import * as React from 'react';
|
|
4
4
|
import { DeviceOrientationControls as DeviceOrientationControls$1 } from 'three-stdlib';
|
|
5
5
|
|
|
6
|
-
const DeviceOrientationControls =
|
|
6
|
+
const DeviceOrientationControls = /* @__PURE__ */React.forwardRef((props, ref) => {
|
|
7
7
|
const {
|
|
8
8
|
camera,
|
|
9
9
|
onChange,
|
package/core/Edges.js
CHANGED
package/core/Effects.js
CHANGED
package/core/Example.js
CHANGED
|
@@ -3,7 +3,7 @@ import { Text3D } from './Text3D.js';
|
|
|
3
3
|
import { Center } from './Center.js';
|
|
4
4
|
|
|
5
5
|
/* eslint react-hooks/exhaustive-deps: 1 */
|
|
6
|
-
const Example =
|
|
6
|
+
const Example = /* @__PURE__ */React.forwardRef(({
|
|
7
7
|
font,
|
|
8
8
|
color = '#cbcbcb',
|
|
9
9
|
bevelSize = 0.04,
|
package/core/FaceControls.js
CHANGED
|
@@ -23,8 +23,8 @@ function localToLocal(objSrc, v, objDst) {
|
|
|
23
23
|
//
|
|
24
24
|
//
|
|
25
25
|
//
|
|
26
|
-
const FaceControlsContext =
|
|
27
|
-
const FaceControls =
|
|
26
|
+
const FaceControlsContext = /* @__PURE__ */createContext({});
|
|
27
|
+
const FaceControls = /* @__PURE__ */forwardRef(({
|
|
28
28
|
camera,
|
|
29
29
|
autostart = true,
|
|
30
30
|
webcam = true,
|
|
@@ -233,7 +233,7 @@ const useFaceControls = () => useContext(FaceControlsContext);
|
|
|
233
233
|
//
|
|
234
234
|
// Webcam
|
|
235
235
|
//
|
|
236
|
-
const Webcam =
|
|
236
|
+
const Webcam = /* @__PURE__ */forwardRef(({
|
|
237
237
|
videoTextureSrc,
|
|
238
238
|
autostart = true
|
|
239
239
|
}, fref) => {
|
|
@@ -275,7 +275,7 @@ const Webcam = /*#__PURE__*/forwardRef(({
|
|
|
275
275
|
//
|
|
276
276
|
// VideoTexture
|
|
277
277
|
//
|
|
278
|
-
const VideoTexture =
|
|
278
|
+
const VideoTexture = /* @__PURE__ */forwardRef(({
|
|
279
279
|
src,
|
|
280
280
|
start
|
|
281
281
|
}, fref) => {
|
package/core/FaceLandmarker.js
CHANGED
|
@@ -4,7 +4,7 @@ import { FilesetResolver, FaceLandmarker as FaceLandmarker$1 } from '@mediapipe/
|
|
|
4
4
|
import { suspend, clear } from 'suspend-react';
|
|
5
5
|
|
|
6
6
|
/* eslint react-hooks/exhaustive-deps: 1 */
|
|
7
|
-
const FaceLandmarkerContext =
|
|
7
|
+
const FaceLandmarkerContext = /* @__PURE__ */createContext({});
|
|
8
8
|
const FaceLandmarkerDefaults = {
|
|
9
9
|
basePath: 'https://cdn.jsdelivr.net/npm/@mediapipe/tasks-vision@0.10.2/wasm',
|
|
10
10
|
options: {
|
package/core/Facemesh.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import * as THREE from 'three';
|
|
3
3
|
export type MediaPipeFaceMesh = typeof FacemeshDatas.SAMPLE_FACE;
|
|
4
|
-
export type MediaPipePoints = typeof FacemeshDatas.SAMPLE_FACE.keypoints | typeof FacemeshDatas.SAMPLE_FACELANDMARKER_RESULT.faceLandmarks[0];
|
|
4
|
+
export type MediaPipePoints = typeof FacemeshDatas.SAMPLE_FACE.keypoints | (typeof FacemeshDatas.SAMPLE_FACELANDMARKER_RESULT.faceLandmarks)[0];
|
|
5
5
|
export type FacemeshProps = {
|
|
6
6
|
points?: MediaPipePoints;
|
|
7
7
|
face?: MediaPipeFaceMesh;
|
|
@@ -10,10 +10,10 @@ export type FacemeshProps = {
|
|
|
10
10
|
depth?: number;
|
|
11
11
|
verticalTri?: [number, number, number];
|
|
12
12
|
origin?: number | THREE.Vector3;
|
|
13
|
-
facialTransformationMatrix?: typeof FacemeshDatas.SAMPLE_FACELANDMARKER_RESULT.facialTransformationMatrixes[0];
|
|
13
|
+
facialTransformationMatrix?: (typeof FacemeshDatas.SAMPLE_FACELANDMARKER_RESULT.facialTransformationMatrixes)[0];
|
|
14
14
|
offset?: boolean;
|
|
15
15
|
offsetScalar?: number;
|
|
16
|
-
faceBlendshapes?: typeof FacemeshDatas.SAMPLE_FACELANDMARKER_RESULT.faceBlendshapes[0];
|
|
16
|
+
faceBlendshapes?: (typeof FacemeshDatas.SAMPLE_FACELANDMARKER_RESULT.faceBlendshapes)[0];
|
|
17
17
|
eyes?: boolean;
|
|
18
18
|
eyesAsOrigin?: boolean;
|
|
19
19
|
debug?: boolean;
|
package/core/Facemesh.js
CHANGED
|
@@ -4,8 +4,8 @@ import { useThree } from '@react-three/fiber';
|
|
|
4
4
|
import { Line } from './Line.js';
|
|
5
5
|
|
|
6
6
|
/* eslint react-hooks/exhaustive-deps: 1 */
|
|
7
|
-
const defaultLookAt = new THREE.Vector3(0, 0, -1);
|
|
8
|
-
const normal = function () {
|
|
7
|
+
const defaultLookAt = /* @__PURE__ */new THREE.Vector3(0, 0, -1);
|
|
8
|
+
const normal = /* @__PURE__ */function () {
|
|
9
9
|
const a = new THREE.Vector3();
|
|
10
10
|
const b = new THREE.Vector3();
|
|
11
11
|
const c = new THREE.Vector3();
|
|
@@ -23,7 +23,7 @@ const normal = function () {
|
|
|
23
23
|
function mean(v1, v2) {
|
|
24
24
|
return v1.clone().add(v2).multiplyScalar(0.5);
|
|
25
25
|
}
|
|
26
|
-
const Facemesh =
|
|
26
|
+
const Facemesh = /* @__PURE__ */React.forwardRef(({
|
|
27
27
|
points = FacemeshDatas.SAMPLE_FACELANDMARKER_RESULT.faceLandmarks[0],
|
|
28
28
|
face,
|
|
29
29
|
facialTransformationMatrix,
|
|
@@ -241,7 +241,7 @@ const FacemeshEyeDefaults = {
|
|
|
241
241
|
vertical: 90
|
|
242
242
|
}
|
|
243
243
|
};
|
|
244
|
-
const FacemeshEye =
|
|
244
|
+
const FacemeshEye = /* @__PURE__ */React.forwardRef(({
|
|
245
245
|
side,
|
|
246
246
|
debug = true
|
|
247
247
|
}, fref) => {
|
|
@@ -3,7 +3,7 @@ import * as React from 'react';
|
|
|
3
3
|
import { useThree, useFrame } from '@react-three/fiber';
|
|
4
4
|
import { FirstPersonControls as FirstPersonControls$1 } from 'three-stdlib';
|
|
5
5
|
|
|
6
|
-
const FirstPersonControls =
|
|
6
|
+
const FirstPersonControls = /* @__PURE__ */React.forwardRef(({
|
|
7
7
|
domElement,
|
|
8
8
|
makeDefault,
|
|
9
9
|
...props
|
package/core/Float.js
CHANGED
|
@@ -3,7 +3,7 @@ import { useFrame } from '@react-three/fiber';
|
|
|
3
3
|
import mergeRefs from 'react-merge-refs';
|
|
4
4
|
import * as THREE from 'three';
|
|
5
5
|
|
|
6
|
-
const Float =
|
|
6
|
+
const Float = /* @__PURE__ */React.forwardRef(({
|
|
7
7
|
children,
|
|
8
8
|
enabled = true,
|
|
9
9
|
speed = 1,
|
package/core/FlyControls.js
CHANGED
|
@@ -3,7 +3,7 @@ import { useThree, useFrame } from '@react-three/fiber';
|
|
|
3
3
|
import * as React from 'react';
|
|
4
4
|
import { FlyControls as FlyControls$1 } from 'three-stdlib';
|
|
5
5
|
|
|
6
|
-
const FlyControls =
|
|
6
|
+
const FlyControls = /* @__PURE__ */React.forwardRef(({
|
|
7
7
|
domElement,
|
|
8
8
|
...props
|
|
9
9
|
}, fref) => {
|
package/core/GizmoHelper.js
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { useThree, useFrame } from '@react-three/fiber';
|
|
3
|
-
import { Object3D, Matrix4, Quaternion
|
|
3
|
+
import { Vector3, Object3D, Matrix4, Quaternion } from 'three';
|
|
4
4
|
import { OrthographicCamera } from './OrthographicCamera.js';
|
|
5
5
|
import { Hud } from './Hud.js';
|
|
6
6
|
|
|
7
|
-
const Context =
|
|
7
|
+
const Context = /* @__PURE__ */React.createContext({});
|
|
8
8
|
const useGizmoContext = () => {
|
|
9
9
|
return React.useContext(Context);
|
|
10
10
|
};
|
|
11
11
|
const turnRate = 2 * Math.PI; // turn rate in angles per second
|
|
12
|
-
const dummy = new Object3D();
|
|
13
|
-
const matrix = new Matrix4();
|
|
14
|
-
const [q1, q2] = [new Quaternion(), new Quaternion()];
|
|
15
|
-
const target = new Vector3();
|
|
16
|
-
const targetPosition = new Vector3();
|
|
12
|
+
const dummy = /* @__PURE__ */new Object3D();
|
|
13
|
+
const matrix = /* @__PURE__ */new Matrix4();
|
|
14
|
+
const [q1, q2] = [/* @__PURE__ */new Quaternion(), /* @__PURE__ */new Quaternion()];
|
|
15
|
+
const target = /* @__PURE__ */new Vector3();
|
|
16
|
+
const targetPosition = /* @__PURE__ */new Vector3();
|
|
17
17
|
const isOrbitControls = controls => {
|
|
18
18
|
return 'minPolarAngle' in controls;
|
|
19
19
|
};
|
package/core/GizmoViewcube.js
CHANGED
|
@@ -12,10 +12,10 @@ const colors = {
|
|
|
12
12
|
};
|
|
13
13
|
const defaultFaces = ['Right', 'Left', 'Top', 'Bottom', 'Front', 'Back'];
|
|
14
14
|
const makePositionVector = xyz => new Vector3(...xyz).multiplyScalar(0.38);
|
|
15
|
-
const corners = [[1, 1, 1], [1, 1, -1], [1, -1, 1], [1, -1, -1], [-1, 1, 1], [-1, 1, -1], [-1, -1, 1], [-1, -1, -1]].map(makePositionVector);
|
|
15
|
+
const corners = /* @__PURE__ */[[1, 1, 1], [1, 1, -1], [1, -1, 1], [1, -1, -1], [-1, 1, 1], [-1, 1, -1], [-1, -1, 1], [-1, -1, -1]].map(makePositionVector);
|
|
16
16
|
const cornerDimensions = [0.25, 0.25, 0.25];
|
|
17
|
-
const edges = [[1, 1, 0], [1, 0, 1], [1, 0, -1], [1, -1, 0], [0, 1, 1], [0, 1, -1], [0, -1, 1], [0, -1, -1], [-1, 1, 0], [-1, 0, 1], [-1, 0, -1], [-1, -1, 0]].map(makePositionVector);
|
|
18
|
-
const edgeDimensions = edges.map(edge => edge.toArray().map(axis => axis == 0 ? 0.5 : 0.25));
|
|
17
|
+
const edges = /* @__PURE__ */[[1, 1, 0], [1, 0, 1], [1, 0, -1], [1, -1, 0], [0, 1, 1], [0, 1, -1], [0, -1, 1], [0, -1, -1], [-1, 1, 0], [-1, 0, 1], [-1, 0, -1], [-1, -1, 0]].map(makePositionVector);
|
|
18
|
+
const edgeDimensions = /* @__PURE__ */edges.map(edge => edge.toArray().map(axis => axis == 0 ? 0.5 : 0.25));
|
|
19
19
|
const FaceMaterial = ({
|
|
20
20
|
hover,
|
|
21
21
|
index,
|
package/core/Gltf.js
CHANGED