|
1 | 1 | --- |
2 | 2 | desc: This page explains how to use 3D rendering in your mod! |
3 | | -lastUpdated: 2024-09-11T15:57:10.000Z |
| 3 | +lastUpdated: 2025-09-08T20:53:00.000Z |
4 | 4 | title: 3D rendering |
5 | 5 | --- |
6 | 6 | # 3D rendering |
7 | 7 |
|
8 | | -coming soon, its in the engine, but not yet documented |
| 8 | +In Codename Engine, there is Away3D integration with a few tools to make the process easier for you. |
| 9 | + |
| 10 | +Here's a simple way to add a Cube primitive into your scene. |
| 11 | +Just take this method and apply it to a stage or something, and you'll get your cube. Though you'll need to do more work to get the cameras and their perspectives to line up correctly. a sugge |
| 12 | +```haxe |
| 13 | +import flx3d.Flx3DView; |
| 14 | +
|
| 15 | +import away3d.entities.Mesh; |
| 16 | +import away3d.primitives.CubeGeometry; |
| 17 | +
|
| 18 | +function create() { |
| 19 | + cube = new Mesh(new CubeGeometry()); // This is your Cube |
| 20 | + cube.z -= 200; // Move it back a bit so you can see it on the camera |
| 21 | + cube.rotationY = 23; // Add some rotation so you can see it's 3D |
| 22 | + cube.rotationX = 45; |
| 23 | +
|
| 24 | + scene3D = new Flx3DView(0, 0, FlxG.width, FlxG.height); // This is what's creating the 3D world |
| 25 | + scene3D.screenCenter(); |
| 26 | + scene3D.addChild(cube); |
| 27 | +
|
| 28 | + add(scene3D); // The 3D View works just like any other sprite so it will have to be added like one |
| 29 | +} |
| 30 | +``` |
| 31 | + |
| 32 | +## Temporary information (clean up later) |
| 33 | + |
| 34 | +From now on, assume that `scene3D` is set up like this |
| 35 | +```haxe |
| 36 | +scene3D = new Flx3DView(0, 0, FlxG.width, FlxG.height); |
| 37 | +``` |
| 38 | + |
| 39 | +Here's just a few function I found that I think would be useful to know about |
| 40 | + |
| 41 | +```haxe |
| 42 | +scene3D.addModel(assetPath:String, callback:Asset3DEvent->Void, ?texturePath:String, smoothTexture:Bool = true); |
| 43 | +
|
| 44 | +scene3D.addChild(childObject); |
| 45 | +``` |
0 commit comments