3DObject and cannon-es.js Construct 3D and 3D collision and physics
A simple example integrating 3DObject with cannon-es.js (javascript 3D physics library.)
Since C3 does not have a 3D physics/collision system, we can leverage an external library to implement it.
The example includes joining a 3DObject and a cannon body together through a new 3DObject scripting interface:
setCannonBody(body, setRotation) - body: a reference to a cannon body - setRotation: boolean
If setRotation is true, the 3DObject rotates with the rotation of the cannon body.
The 3DObject will follow the cannon body's x,y,z location and rotation. No other C3 events are required, the location and rotation are set for the 3DObject every tick.
The example also includes setting a 3DObject position and cannon body position based on a C3 sprite orbiting a point (it does not set the rotation of the cannon body, so collision may be a little off. I leave this an exercise for the reader.)
The cannon-es.js library is pretty nice and very comprehensive. It can also do things like call functions on collision (addListener('collision', ...) ), etc. This can be integrated with C3 through JS scripting
Currently, I don't plan on working on a cannon-es.js plug-in/behavior for C3, however, I am very willing to help with any 3DObject integration with such a plug-in in case another developer creates one.
Files
Get Construct 3 3DObject Plugin
Construct 3 3DObject Plugin
Construct 3 3DObject, loaded from 3D model files (gltf embedded format)
Status | Released |
Category | Assets |
Author | kindeyegames |
Tags | 3D, construct, construct-3 |
More posts
- fix (addon) fix corrupted addon9 days ago
- fix (accessors) add support for sparse accessors in gltf10 days ago
- Fix (node-disable) fix node disable without skinned node30 days ago
- fix (node-disable) regression36 days ago
- Fix (playable Ad)48 days ago
- fix (worker) correct animation blend for worker (translation)65 days ago
- fix (opacity)71 days ago
- add (sample) sample gpu-skin with phong light84 days ago
- fix (gpu-skinning) fix regression for worker mode84 days ago
- fix (light) fix for simple phong orientation85 days ago
Comments
Log in with itch.io to leave a comment.
I'm having issues loading image textures on the model, the image gets stretched out to form tiny pieces on the model
Have you tried the latest version 2-24-1?
If does not work with that, can you share your model (I use sendgb.com to share files).
Hi, Thanks for the feed back I'm using the latest version but here is the model the texture is embeded https://sendgb.com/uO3Xr86H4lR
It looks like this model does not actually have a diffuse texture/material on the model, just an emissive texture (as the add-on notes mention, only diffuse / albedo texture is supported.)
I suggest either adding a diffuse texture to the model in a 3d tool like belnder or using a different model.
You can check out model /material properties by loading into: https://sandbox.babylonjs.com/
I worked on the project all night yesterday and everything was fine until I launched it today! What is the problem and will it be fixed?
Error report information
Type: unhandled rejection Reason: Error: Cannot read properties of undefined (reading 'width') @ TypeError: Cannot read properties of undefined (reading 'width') at Object3DType.LoadDynamicTextures (blob:https://editor.construct.net/796e0b60-df29-450d-a879-e16972d18c40:26:53) at Object3DInstance.Draw (blob:https://editor.construct.net/3e5bf2ec-88bf-4fac-9ae7-2337805b2e81:111:40) Stack: TypeError: Cannot read properties of undefined (reading 'width') at Object3DType.LoadDynamicTextures (blob:https://editor.construct.net/796e0b60-df29-450d-a879-e16972d18c40:26:53) at Object3DInstance.Draw (blob:https://editor.construct.net/3e5bf2ec-88bf-4fac-9ae7-2337805b2e81:111:40) Construct 3 version: r289 URL: https://editor.construct.net/r289/ Date: Mon Apr 18 2022 16:14:24 GMT+0300 (Москва, стандартное время) Uptime: 47.9 s
Platform information
Browser: Chrome Browser version: 98.0.4758.132 Browser engine: Chromium Context: browser Operating system: Windows Operating system version: 10 Device type: desktop Device pixel ratio: 1 Logical CPU cores: 8 Approx. device memory: 8 GB User agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/98.0.4758.132 YaBrowser/22.3.1.892 Yowser/2.5 Safari/537.36 C3 release: r289 (beta) Language setting: en-US
WebGL information
Version string: WebGL 2.0 (OpenGL ES 3.0 Chromium) Numeric version: 2 Supports NPOT textures: yes Supports GPU profiling: yes Supports highp precision: yes Vendor: Google Inc. (AMD) Renderer: ANGLE (AMD, AMD Radeon RX 6600 Direct3D11 vs_5_0 ps_5_0, D3D11-30.0.15019.1005) Major performance caveat: no Maximum texture size: 16384 Point size range: 1 to 1024 Extensions: EXT_color_buffer_float, EXT_color_buffer_half_float, EXT_disjoint_timer_query_webgl2, EXT_float_blend, EXT_texture_compression_bptc, EXT_texture_compression_rgtc, EXT_texture_filter_anisotropic, EXT_texture_norm16, KHR_parallel_shader_compile, OES_texture_float_linear, WEBGL_compressed_texture_s3tc, WEBGL_compressed_texture_s3tc_srgb, WEBGL_debug_renderer_info, WEBGL_debug_shaders, WEBGL_lose_context, WEBGL_multi_draw, OVR_multiview2
Can you share your project? If you want to share privately, you can contact me on the Construct Community Discord, username Mikal.
I sent
with shadow?
No shadow.
Where to get models? Everything I take on sketchfab doesn't work.
turbosquid, itch.io cgtrader, convert to glb with blender if needed.
Can you send a link to a specific sketch fab model that did not work?
https://sketchfab.com/3d-models/bonnie-glb-file-26b2a6f266514e6ea7c2fc1dbc0be9e2
Please try the updated plug-in 2-24-1, it should now handle files without names for the images (which was the case for the link you provided, thanks for providing the link.)
Here's an example project with the above model, which works for me with the latest plug-in.
https://sendgb.com/Teqwd72JGQv