@react-three/drei 9.88.14 → 9.88.16
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/README.md +23 -3
- package/core/useBVH.cjs.js +1 -1
- package/core/useBVH.d.ts +1 -0
- package/core/useBVH.js +5 -2
- package/index.cjs.js +1 -1
- package/package.json +1 -1
- package/react-three-drei-0.0.0-semantic-release.tgz +0 -0
- package/web/CycleRaycast.cjs.js +1 -1
- package/web/CycleRaycast.js +1 -1
package/README.md
CHANGED
|
@@ -1769,10 +1769,12 @@ The decal box has to intersect the surface, otherwise it will not be visible. if
|
|
|
1769
1769
|
position={[0, 0, 0]} // Position of the decal
|
|
1770
1770
|
rotation={[0, 0, 0]} // Rotation of the decal (can be a vector or a degree in radians)
|
|
1771
1771
|
scale={1} // Scale of the decal
|
|
1772
|
-
polygonOffset
|
|
1773
|
-
polygonOffsetFactor={-1} // The mesh should take precedence over the original
|
|
1774
1772
|
>
|
|
1775
|
-
<meshBasicMaterial
|
|
1773
|
+
<meshBasicMaterial
|
|
1774
|
+
map={texture}
|
|
1775
|
+
polygonOffset
|
|
1776
|
+
polygonOffsetFactor={-1} // The material should take precedence over the original
|
|
1777
|
+
/>
|
|
1776
1778
|
</Decal>
|
|
1777
1779
|
</mesh>
|
|
1778
1780
|
```
|
|
@@ -2369,6 +2371,16 @@ Enable shadows using the `castShadow` and `recieveShadow` prop.
|
|
|
2369
2371
|
|
|
2370
2372
|
> Note: Html 'blending' mode only correctly occludes rectangular HTML elements by default. Use the `geometry` prop to swap the backing geometry to a custom one if your Html has a different shape.
|
|
2371
2373
|
|
|
2374
|
+
If transform mode is enabled, the dimensions of the rendered html will depend on the position relative to the camera, the camera fov and the distanceFactor. For example, an Html component placed at (0,0,0) and with a distanceFactor of 10, rendered inside a scene with a perspective camera positioned at (0,0,2.45) and a FOV of 75, will have the same dimensions as a "plain" html element like in [this example](https://codesandbox.io/s/drei-html-magic-number-6mzt6m).
|
|
2375
|
+
|
|
2376
|
+
A caveat of transform mode is that on some devices and browsers, the rendered html may appear blurry, as discussed in [#859](https://github.com/pmndrs/drei/issues/859). The issue can be at least mitigated by scaling down the Html parent and scaling up the html children:
|
|
2377
|
+
|
|
2378
|
+
```jsx
|
|
2379
|
+
<Html transform scale={0.5}>
|
|
2380
|
+
<div style={{ transform: "scale(2)" }}>Some text</div>
|
|
2381
|
+
</Html>
|
|
2382
|
+
```
|
|
2383
|
+
|
|
2372
2384
|
#### CycleRaycast
|
|
2373
2385
|
|
|
2374
2386
|

|
|
@@ -3351,6 +3363,14 @@ export interface BVHOptions {
|
|
|
3351
3363
|
maxDepth?: number
|
|
3352
3364
|
/** The number of triangles to aim for in a leaf node, default: 10 */
|
|
3353
3365
|
maxLeafTris?: number
|
|
3366
|
+
/** If false then an index buffer is created if it does not exist and is rearranged */
|
|
3367
|
+
/** to hold the bvh structure. If false then a separate buffer is created to store the */
|
|
3368
|
+
/** structure and the index buffer (or lack thereof) is retained. This can be used */
|
|
3369
|
+
/** when the existing index layout is important or groups are being used so a */
|
|
3370
|
+
/** single BVH hierarchy can be created to improve performance. */
|
|
3371
|
+
/** default: false */
|
|
3372
|
+
/** Note: This setting is experimental */
|
|
3373
|
+
indirect?: boolean
|
|
3354
3374
|
}
|
|
3355
3375
|
|
|
3356
3376
|
export type BvhProps = BVHOptions &
|
package/core/useBVH.cjs.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@babel/runtime/helpers/extends"),r=require("@react-three/fiber"),t=require("react"),s=require("three"),o=require("three-mesh-bvh");function
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@babel/runtime/helpers/extends"),r=require("@react-three/fiber"),t=require("react"),s=require("three"),o=require("three-mesh-bvh");function n(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 s=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,s.get?s:{enumerable:!0,get:function(){return e[t]}})}})),r.default=e,Object.freeze(r)}var a=n(e),c=u(t);const i=e=>e.isMesh;const d=c.forwardRef((({enabled:e=!0,firstHitOnly:t=!1,children:n,strategy:u=o.SAH,verbose:d=!1,setBoundingBox:f=!0,maxDepth:p=40,maxLeafTris:y=10,indirect:l=!1,...m},B)=>{const b=c.useRef(null),T=r.useThree((e=>e.raycaster));return c.useImperativeHandle(B,(()=>b.current),[]),c.useEffect((()=>{if(e){const e={strategy:u,verbose:d,setBoundingBox:f,maxDepth:p,maxLeafTris:y,indirect:l},r=b.current;return T.firstHitOnly=t,r.traverse((r=>{i(r)&&!r.geometry.boundsTree&&r.raycast===s.Mesh.prototype.raycast&&(r.raycast=o.acceleratedRaycast,r.geometry.computeBoundsTree=o.computeBoundsTree,r.geometry.disposeBoundsTree=o.disposeBoundsTree,r.geometry.computeBoundsTree(e))})),()=>{delete T.firstHitOnly,r.traverse((e=>{i(e)&&e.geometry.boundsTree&&(e.geometry.disposeBoundsTree(),e.raycast=s.Mesh.prototype.raycast)}))}}}),[]),c.createElement("group",a.default({ref:b},m),n)}));exports.Bvh=d,exports.useBVH=function(e,r){r={strategy:o.SAH,verbose:!1,setBoundingBox:!0,maxDepth:40,maxLeafTris:10,indirect:!1,...r},c.useEffect((()=>{if(e.current){e.current.raycast=o.acceleratedRaycast;const t=e.current.geometry;return t.computeBoundsTree=o.computeBoundsTree,t.disposeBoundsTree=o.disposeBoundsTree,t.computeBoundsTree(r),()=>{t.boundsTree&&t.disposeBoundsTree()}}}),[e,JSON.stringify(r)])};
|
package/core/useBVH.d.ts
CHANGED
package/core/useBVH.js
CHANGED
|
@@ -16,6 +16,7 @@ function useBVH(mesh, options) {
|
|
|
16
16
|
setBoundingBox: true,
|
|
17
17
|
maxDepth: 40,
|
|
18
18
|
maxLeafTris: 10,
|
|
19
|
+
indirect: false,
|
|
19
20
|
...options
|
|
20
21
|
};
|
|
21
22
|
React.useEffect(() => {
|
|
@@ -42,6 +43,7 @@ const Bvh = /* @__PURE__ */React.forwardRef(({
|
|
|
42
43
|
setBoundingBox = true,
|
|
43
44
|
maxDepth = 40,
|
|
44
45
|
maxLeafTris = 10,
|
|
46
|
+
indirect = false,
|
|
45
47
|
...props
|
|
46
48
|
}, fref) => {
|
|
47
49
|
const ref = React.useRef(null);
|
|
@@ -54,7 +56,8 @@ const Bvh = /* @__PURE__ */React.forwardRef(({
|
|
|
54
56
|
verbose,
|
|
55
57
|
setBoundingBox,
|
|
56
58
|
maxDepth,
|
|
57
|
-
maxLeafTris
|
|
59
|
+
maxLeafTris,
|
|
60
|
+
indirect
|
|
58
61
|
};
|
|
59
62
|
const group = ref.current;
|
|
60
63
|
// This can only safely work if the component is used once, but there is no alternative.
|
|
@@ -80,7 +83,7 @@ const Bvh = /* @__PURE__ */React.forwardRef(({
|
|
|
80
83
|
});
|
|
81
84
|
};
|
|
82
85
|
}
|
|
83
|
-
});
|
|
86
|
+
}, []);
|
|
84
87
|
return /*#__PURE__*/React.createElement("group", _extends({
|
|
85
88
|
ref: ref
|
|
86
89
|
}, props), children);
|