@tscircuit/3d-viewer 0.0.346 → 0.0.348
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +14 -5
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -25455,11 +25455,12 @@ var Html = ({ children, position, style }) => {
|
|
|
25455
25455
|
if (!camera || !el.current || !renderer) return;
|
|
25456
25456
|
const vector = new THREE5.Vector3(...position);
|
|
25457
25457
|
vector.project(camera);
|
|
25458
|
-
const
|
|
25459
|
-
const
|
|
25458
|
+
const rect = renderer.domElement.getBoundingClientRect();
|
|
25459
|
+
const x = Math.round((vector.x + 1) / 2 * rect.width);
|
|
25460
|
+
const y = Math.round((-vector.y + 1) / 2 * rect.height);
|
|
25460
25461
|
el.current.style.position = "absolute";
|
|
25461
|
-
el.current.style.left = `${x}px`;
|
|
25462
|
-
el.current.style.top = `${y}px`;
|
|
25462
|
+
el.current.style.left = `${rect.left + x}px`;
|
|
25463
|
+
el.current.style.top = `${rect.top + y}px`;
|
|
25463
25464
|
el.current.style.pointerEvents = "none";
|
|
25464
25465
|
if (style) {
|
|
25465
25466
|
Object.assign(el.current.style, style);
|
|
@@ -25582,7 +25583,7 @@ import * as THREE10 from "three";
|
|
|
25582
25583
|
// package.json
|
|
25583
25584
|
var package_default = {
|
|
25584
25585
|
name: "@tscircuit/3d-viewer",
|
|
25585
|
-
version: "0.0.
|
|
25586
|
+
version: "0.0.347",
|
|
25586
25587
|
main: "./dist/index.js",
|
|
25587
25588
|
module: "./dist/index.js",
|
|
25588
25589
|
type: "module",
|
|
@@ -25846,6 +25847,13 @@ import {
|
|
|
25846
25847
|
useMemo as useMemo8
|
|
25847
25848
|
} from "react";
|
|
25848
25849
|
import * as THREE7 from "three";
|
|
25850
|
+
|
|
25851
|
+
// src/react-three/remove-existing-canvases.ts
|
|
25852
|
+
function removeExistingCanvases(container) {
|
|
25853
|
+
container.querySelectorAll("canvas").forEach((existingCanvas) => existingCanvas.remove());
|
|
25854
|
+
}
|
|
25855
|
+
|
|
25856
|
+
// src/react-three/Canvas.tsx
|
|
25849
25857
|
import { jsx as jsx9 } from "react/jsx-runtime";
|
|
25850
25858
|
var Canvas = forwardRef(
|
|
25851
25859
|
({ children, scene: sceneProps, camera: cameraProps, style }, ref) => {
|
|
@@ -25878,6 +25886,7 @@ var Canvas = forwardRef(
|
|
|
25878
25886
|
useImperativeHandle(ref, () => rootObject.current);
|
|
25879
25887
|
useEffect10(() => {
|
|
25880
25888
|
if (!mountRef.current) return;
|
|
25889
|
+
removeExistingCanvases(mountRef.current);
|
|
25881
25890
|
const renderer = new THREE7.WebGLRenderer({ antialias: true, alpha: true });
|
|
25882
25891
|
renderer.setSize(
|
|
25883
25892
|
mountRef.current.clientWidth,
|