swift - How can i add a 2dView having text in ARkit scene iOS -


how can add 2dview having text in arkit scene ios.how can add view in top of node won't rotate when rotate node.enter image description here

you can add scnplane , use scnlookatconstraint plane looks @ camera.

you can create custom material , set it's material properties to:

  • a color (uicolor or cgcolor), specifying constant color across material’s surface number (

  • an image (uiimage or cgimage), specifying texture mapped across material’s surface

  • a core animation layer (calayer)
  • a texture (sktexture, mdltexture, mtltexture, or glktextureinfo)
  • a spritekit scene (skscene)

you can display animated contents using coreanimation or spritekit but

scenekit cannot use layer being displayed elsewhere (for example, backing layer of uiview object)


here example using spritekit:

  1. create spritekit scene:

e.g.:

let skscene = skscene(size: cgsize(width: 200, height: 200)) skscene.backgroundcolor = uicolor.clear  let rectangle = skshapenode(rect: cgrect(x: 0, y: 0, width: 200, height: 200), cornerradius: 10) 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) skscene.addchild(rectangle) skscene.addchild(labelnode) 
  1. create plane , set scene material property

e.g.

let plane = scnplane(width: 20, height: 20) let material = scnmaterial() material.isdoublesided = true material.diffuse.contents = skscene plane.materials = [material] let node = scnnode(geometry: plane) scene.rootnode.addchildnode(node) 
  1. animate scene

e.g.

labelnode.run(skaction.repeatforever(skaction.rotate(byangle: .pi, duration: 2))) 

enter image description here


Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -