@tscircuit/3d-viewer 0.0.373 → 0.0.374

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.
Files changed (2) hide show
  1. package/dist/index.js +25 -7
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -14416,7 +14416,28 @@ var ContainerWithTooltip_default = ContainerWithTooltip;
14416
14416
 
14417
14417
  // src/hooks/use-global-obj-loader.ts
14418
14418
  import { useState as useState2, useEffect as useEffect3 } from "react";
14419
- import { MTLLoader, OBJLoader, VRMLLoader } from "three-stdlib";
14419
+ import { MTLLoader, OBJLoader } from "three-stdlib";
14420
+
14421
+ // src/utils/vrml.ts
14422
+ import { VRMLLoader } from "three-stdlib";
14423
+ function sanitizeVrmlIdentifiers(text) {
14424
+ return text.replace(/(DEF|USE)\s+([^\s]+)/g, (match, type, name) => {
14425
+ return `${type} ${name.replace(/-/g, "_")}`;
14426
+ });
14427
+ }
14428
+ async function loadVrml(url) {
14429
+ const response = await fetch(url);
14430
+ if (!response.ok) {
14431
+ throw new Error(
14432
+ `Failed to fetch "${url}": ${response.status} ${response.statusText}`
14433
+ );
14434
+ }
14435
+ const text = await response.text();
14436
+ const loader = new VRMLLoader();
14437
+ return loader.parse(sanitizeVrmlIdentifiers(text), url);
14438
+ }
14439
+
14440
+ // src/hooks/use-global-obj-loader.ts
14420
14441
  if (typeof window !== "undefined" && !window.TSCIRCUIT_OBJ_LOADER_CACHE) {
14421
14442
  window.TSCIRCUIT_OBJ_LOADER_CACHE = /* @__PURE__ */ new Map();
14422
14443
  }
@@ -14430,8 +14451,7 @@ function useGlobalObjLoader(url) {
14430
14451
  async function loadAndParseObj() {
14431
14452
  try {
14432
14453
  if (cleanUrl.endsWith(".wrl")) {
14433
- const loader = new VRMLLoader();
14434
- return await loader.loadAsync(cleanUrl);
14454
+ return await loadVrml(cleanUrl);
14435
14455
  }
14436
14456
  const response = await fetch(cleanUrl);
14437
14457
  if (!response.ok) {
@@ -25959,7 +25979,7 @@ import * as THREE11 from "three";
25959
25979
  // package.json
25960
25980
  var package_default = {
25961
25981
  name: "@tscircuit/3d-viewer",
25962
- version: "0.0.372",
25982
+ version: "0.0.373",
25963
25983
  main: "./dist/index.js",
25964
25984
  module: "./dist/index.js",
25965
25985
  type: "module",
@@ -30046,7 +30066,6 @@ import * as THREE25 from "three";
30046
30066
  import { GLTFLoader as GLTFLoader2 } from "three/examples/jsm/loaders/GLTFLoader.js";
30047
30067
  import { OBJLoader as OBJLoader2 } from "three/examples/jsm/loaders/OBJLoader.js";
30048
30068
  import { STLLoader as STLLoader2 } from "three/examples/jsm/loaders/STLLoader.js";
30049
- import { VRMLLoader as VRMLLoader2 } from "three/examples/jsm/loaders/VRMLLoader.js";
30050
30069
  async function load3DModel(url) {
30051
30070
  if (url.endsWith(".stl")) {
30052
30071
  const loader = new STLLoader2();
@@ -30063,8 +30082,7 @@ async function load3DModel(url) {
30063
30082
  return await loader.loadAsync(url);
30064
30083
  }
30065
30084
  if (url.endsWith(".wrl")) {
30066
- const loader = new VRMLLoader2();
30067
- return await loader.loadAsync(url);
30085
+ return await loadVrml(url);
30068
30086
  }
30069
30087
  if (url.endsWith(".gltf") || url.endsWith(".glb")) {
30070
30088
  const loader = new GLTFLoader2();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tscircuit/3d-viewer",
3
- "version": "0.0.373",
3
+ "version": "0.0.374",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.js",
6
6
  "type": "module",