Documentation on Three.js #1656
Replies: 3 comments 5 replies
-
|
I don't think your Let's assume without pyscript stuff works ... then you want to do this (order matters): <!DOCTYPE html>
<head>
<link rel="stylesheet" href="https://pyscript.net/latest/pyscript.css"/>
<script type="importmap">
{
"imports": {
"three": "https://threejs.org/build/three.module.js",
"three/addons/": "https://threejs.org/examples/jsm/"
}
}
</script>
<script type="module">
import * as THREE from 'three';
globalThis.THREE = THREE;
</script>
<script defer src="https://pyscript.net/latest/pyscript.js"></script>
</head>
<body>
But suppose that you would like to rotate a figure about a point that is NOT the origin! Like this:
<py-script src="./pyscript.py"></py-script>
<!-- what's in here? -->
<script src="./cube.js" type="module"></script>
<canvas id="c" width="500px" height="500px"></canvas>
</body>
</html>Also, to help us help you, please stay away from polyfills 'cause also no polyfill can fix importmap at all because that's backed into the JS syntax, as native |
Beta Was this translation helpful? Give feedback.
-
|
I am having challenges importing some of the three.js modules into my script. My html I have an import map My pyscript.toml In my script I am importing the modules as follows This works fine with THREE and OrbitControls. However, if I try to import BufferGeometryUtils I get the following error What could be the issue here? Thanks |
Beta Was this translation helpful? Give feedback.
-
|
I am trying to visualize voxels (world build up with boxes kind of like mindcraft) That is why I want to use the mergeGeometries function to reduce the drawing load for threejs. The code below tries to merge outline of the cubes and viz them. However, I keep getting the error |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I'm running into a couple issues trying to figure out how to use Three.js in PyScript. (One has to do with where the renderings are placed in the page and how to change it. The other is about how to use Three.js addons, if that's possible, like for instance CSS2DRenderer.) But from googling and from trying to navigate the documentation on the PyScript website I can't find anything about this. Can anyone point me to where I could learn more about how to use this?
Or maybe even just keywords to try googling -- I tried "pyscript three.js documentation" and didn't find anything. Would you call this a "submodule" of pyscript? Or an addon or something else?
Alternately, maybe someone has a recommendation about how to approach my more general problem. I can load and render Three.js directly without PyScript. I can also load and run PyScript without Three.js. For whatever reason when I try to do both, I get a CORS exception. It seemed like perhaps the ideal solution was to just try to use PyScript's in-built reproduction of Three.js. But perhaps it's better if I just try to find out what's causing the CORS exception and address that directly?
Here is a minimal example which produces the CORS exception:
If it helps, I can show the related JavaScript and so on. But the long story short is that if I remove the Three.js then it's fine, and if I remove the PyScript then it's fine. But with both of them present, I get the CORS exception.
Also the CORS exception seems only related to the addon import, and I don't really get why that would cause a problem but not the other. But I can try to research it if this is a productive thing to do.
Beta Was this translation helpful? Give feedback.
All reactions