簡體   English   中英

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

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

我是 SceneKit 的新手,並且在 SceneKit 上遇到了一些問題,我需要在 3d 模型上添加 2d 對象

現在我已經用 skNode 添加了 2d 對象,但該對象沒有隨 3d 模型移動。

就像我旋轉或放大和縮小 3d 模型一樣,當我們在地圖上添加注釋時,2d 對象也需要與 3d 對象一起移動

這是帶有注釋的 3d 汽車模型鏈接的鏈接,我需要實現這種類型的輸出在此處輸入圖片說明

我已經完成了這種類型的代碼,但對象沒有移動。

   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!")

請幫忙

我們可以通過 SCNNode 添加節點。 它對我有用。

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