简体   繁体   English

使用sceneKit在3d模型上添加2d对象

[英]add 2d object on 3d Model using sceneKit

I am new to SceneKit and some issue on SceneKit, i need to add 2d objects on 3d model我是 SceneKit 的新手,并且在 SceneKit 上遇到了一些问题,我需要在 3d 模型上添加 2d 对象

Right now I already added 2d objects with skNode but that object is not moving with 3d model.现在我已经用 skNode 添加了 2d 对象,但该对象没有随 3d 模型移动。

Like if I rotate or zoomIn and zoomout 3d model then that 2d objects also needs to move with the 3d object, when we add annotations on map就像我旋转或放大和缩小 3d 模型一样,当我们在地图上添加注释时,2d 对象也需要与 3d 对象一起移动

Here is link of 3d car model link with annotations, I need to achieve this type of output这是带有注释的 3d 汽车模型链接的链接,我需要实现这种类型的输出在此处输入图片说明

And I have done this type of code, but object not moving.我已经完成了这种类型的代码,但对象没有移动。

   let rectangle = SKShapeNode(rect: CGRect(x: 0, y: 0, width: 20, height: 20), cornerRadius: 10)
    rectangle.position = CGPoint(x: 50, y: 56)
    rectangle.fillColor = #colorLiteral(red: 0.807843148708344, green: 0.0274509806185961, blue: 0.333333343267441, alpha: 1.0)
    rectangle.strokeColor = #colorLiteral(red: 0.439215689897537, green: 0.0117647061124444, blue: 0.192156866192818, alpha: 1.0)
    rectangle.lineWidth = 5
    rectangle.alpha = 0.4
    let labelNode = SKLabelNode(text: "Hello World")
    labelNode.fontSize = 20
    labelNode.fontName = "San Fransisco"
    labelNode.position = CGPoint(x:100,y:100)
    shipHud.addChild(rectangle)
    shipHud.addChild(labelNode)





    sceneView.overlaySKScene = shipHud// = shipHud


    shipHud.shipHudFlashAlert(alert: "Oh My God!")

Please please help请帮忙

we can add node by SCNNode.我们可以通过 SCNNode 添加节点。 its works for me.它对我有用。

let cubeNode = SCNNode(geometry: SCNBox(width: 2, height: 2, length: 0.1, chamferRadius: 10))
cubeNode.position = SCNVector3(10, -2, -0.2) // SceneKit/AR coordinates are in meters
sceneView.scene?.rootNode.addChildNode(cubeNode)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM