theatre-js / theatre

Motion design editor for the web
https://www.theatrejs.com
Apache License 2.0
10.82k stars 337 forks source link

Can't run three.js basic example #468

Open fedemarino31 opened 6 months ago

fedemarino31 commented 6 months ago

I've just followed the tutorial for Three.js on https://www.theatrejs.com/docs/latest/getting-started/with-three-js And I'm getting the following error: image But the tutorial does not say you should import the "core"

Also on a separate project, I tried importing the core module on a basic three.js project without usign Webpack or Vite. I just wanted to directly import the module using import maps The key parts of the code are:

main.html

    <script type="importmap">
        {
          "imports": {
            "three": "/node_modules/three/build/three.module.js",
            "three/addons/": "/node_modules/three/examples/jsm/",
            "@theatre/":"/node_modules/@theatre/"
          }
        }
    </script>

main.js

import { getProject } from '@theatre/core'

and I'm getting this error

image

I also tried with

import { getProject } from '@theatre/core/dist/index.js'

But it does not seam to export "getProject"

image

any ideas?

I'm using version 0.7.0

GhostCatcg commented 5 months ago

No one can help you with this question, but theatre has its own case study, you can check his case study

gong9 commented 4 months ago

Why, I think it's foolish to not even guarantee basic tutorials and allow this to happen

GhostCatcg commented 4 months ago

The way you import modules is not what the theaterjs tutorial document says. You can try vite or webpack. I think the author has limited maintenance time. If you think it is unreasonable, you can submit a commit.

Why, I think it's foolish to not even guarantee basic tutorials and allow this to happen

gong9 commented 4 months ago

I just took a look at its code, and its studio sub package needs to go to the window to obtain the core package. Therefore, it is necessary to


import studio from '@theatre/studio'
import core from '@theatre/core'

window.__TheatreJS_CoreBundle = core
studio.initialize()