Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Examples throw error, don't seem to import in Three.js #119

Closed
jondavis847 opened this issue Mar 31, 2023 · 3 comments
Closed

Examples throw error, don't seem to import in Three.js #119

jondavis847 opened this issue Mar 31, 2023 · 3 comments

Comments

@jondavis847
Copy link

I recently tried to run the examples in Modia3D. I only installed the package and tried to run each of the examples in the tutorial such as:

include("$(Modia3D.path)/test/Tutorial/Pendulum1.jl")

This throws the following error:
julia> include("$(Modia3D.path)/test/Tutorial/Pendulum1.jl")

Instantiating model Pendulum
in module: Main.Pendulum1
in file: C:\Users\jonda.julia\packages\Modia3D\il61O\test\Tutorial\Pendulum1.jl:11
ERROR:
solution = simulate!(Pendulum, ...) failed with solution.retcode = :Success at time = 3.0.

Stacktrace:
[1] error(::String, ::String, ::String)
@ Base .\error.jl:44
[2] macro expansion
@ C:\Users\jonda.julia\packages\Modia\TXKQS\src\SimulateAndPlot.jl:246 [inlined]
[3] macro expansion
@ C:\Users\jonda.julia\packages\TimerOutputs\LHjFw\src\TimerOutput.jl:237 [inlined]
[4] simulate!(m::Modia.SimulationModel{Float64, Float64}, algorithm::Missing; merge::Nothing, kwargs::Base.Pairs{Symbol, Float64, Tuple{Symbol},
NamedTuple{(:stopTime,), Tuple{Float64}}})
@ Modia C:\Users\jonda.julia\packages\Modia\TXKQS\src\SimulateAndPlot.jl:235
[5] top-level scope
@ C:\Users\jonda.julia\packages\Modia3D\il61O\test\Tutorial\Pendulum1.jl:12

Same error for each of the examples in the tutorial. It does produce the .json files and there appears to be data inside of them. However, if I try to import them into Three.js, nothing happens. The rendered scene just stays empty.

@AndreaNeumayr
Copy link
Member

Did you install the Modia package as well? Please see installation guide. Which Julia version do you use?

Visualization with Three.js:
In example Tutorial/Pendulum1.jl there is nothing to visualize (no 3D shape is defined, etc.). So you don't get a visualization at all.
In example Tutorial/Pendulum2.jl there is a Solid shape (Beam) with visualization properties defined. There you'd get a visualization with Three.js.

Since the example fails with an error you don't get a reasonable visualization.

@GerhardHippmann
Copy link
Collaborator

At the moment animation export is broken because the object names in three.js have been changed (e.g. "SphereBufferGeometry" -> "SphereGeometry"). A fix is implemented but not yet published.

@jondavis847
Copy link
Author

Thanks for the help! Indeed I needed Modia to drop the error when simulating, I had poorly assumed Modia3D would bring Modia with it. I searched for "Buffer" in my .json file for the animation. I found only one instance of a CylinderBufferGeometry. Changing that to CylinderGeometry and importing the .json file to Three.js worked great.

"geometries": [
{
"name": "obj2.geometry",
"uuid": "0bfc5553-48e7-5e27-84a7-3518139b6ca3",
"type": "CylinderBufferGeometry",
"radiusBottom": 0.05,
"radiusTop": 0.05,
"height": 0.21,
"radialSegments": 32,
"heightSegments": 1
},

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants