Added name property to the GLTF loader (#117)
This commit is contained in:
@@ -7,6 +7,7 @@ class Scene(val root: SceneNode = SceneNode(), val dispatcher: Dispatcher = Disp
|
|||||||
|
|
||||||
|
|
||||||
open class SceneNode() {
|
open class SceneNode() {
|
||||||
|
var name: String = ""
|
||||||
var entities: MutableList<Entity> = mutableListOf()
|
var entities: MutableList<Entity> = mutableListOf()
|
||||||
var parent: SceneNode? = null
|
var parent: SceneNode? = null
|
||||||
open var transform = Matrix44.IDENTITY
|
open var transform = Matrix44.IDENTITY
|
||||||
|
|||||||
@@ -28,7 +28,8 @@ class GltfAsset(val generator: String?, val version: String?)
|
|||||||
|
|
||||||
class GltfScene(val nodes: IntArray)
|
class GltfScene(val nodes: IntArray)
|
||||||
|
|
||||||
class GltfNode(val children: IntArray?,
|
class GltfNode(val name:String,
|
||||||
|
val children: IntArray?,
|
||||||
val matrix: DoubleArray?,
|
val matrix: DoubleArray?,
|
||||||
val scale: DoubleArray?,
|
val scale: DoubleArray?,
|
||||||
val rotation: DoubleArray?,
|
val rotation: DoubleArray?,
|
||||||
|
|||||||
@@ -210,6 +210,7 @@ fun GltfFile.buildSceneNodes(): GltfSceneData {
|
|||||||
val sceneNodes = mutableMapOf<GltfNode, SceneNode>()
|
val sceneNodes = mutableMapOf<GltfNode, SceneNode>()
|
||||||
fun GltfNode.createSceneNode(): SceneNode = sceneNodes.getOrPut(this) {
|
fun GltfNode.createSceneNode(): SceneNode = sceneNodes.getOrPut(this) {
|
||||||
val node = GltfSceneNode()
|
val node = GltfSceneNode()
|
||||||
|
node.name = name ?: ""
|
||||||
node.translation = translation?.let { Vector3(it[0], it[1], it[2]) } ?: Vector3.ZERO
|
node.translation = translation?.let { Vector3(it[0], it[1], it[2]) } ?: Vector3.ZERO
|
||||||
node.scale = scale?.let { Vector3(it[0], it[1], it[2]) } ?: Vector3.ONE
|
node.scale = scale?.let { Vector3(it[0], it[1], it[2]) } ?: Vector3.ONE
|
||||||
node.rotation = rotation?.let { Quaternion(it[0], it[1], it[2], it[3]) } ?: Quaternion.IDENTITY
|
node.rotation = rotation?.let { Quaternion(it[0], it[1], it[2], it[3]) } ?: Quaternion.IDENTITY
|
||||||
|
|||||||
Reference in New Issue
Block a user