How to use properties from SCNFloor with Swift and Scenekit? -



How to use properties from SCNFloor with Swift and Scenekit? -

i can't figure out how access properties from the scenekit scnfloor class using swift, in objective-c this:

scnnode*floor = [scnnode node]; floor.geometry = [scnfloor floor]; ((scnfloor*)floor.geometry).reflectionfalloffend = 10;

this creates floor, how acces "reflectionfalloffend"?

let levelfloor = scnnode() levelfloor.geometry = scnfloor()

thanks

edit quick responses works :)

whether you're in objc or swift, compiler happy using scnfloor properties or methods on reference, reference needs have type scnfloor.

you can inline cast:

// objc ((scnfloor*)floor.geometry).reflectionfalloffend = 10; // swift (levelfloor.geometry scnfloor).reflectionfalloffend = 10

but can rather unwieldy, if you're going set bunch of properties on geometry. prefer utilize local variables (or constants, rather, since references don't need change):

let floor = scnfloor() floor.reflectionfalloffend = 10 floor.reflectivity = 0.5 allow floornode = scnnode(geometry: floor) floornode.position = scnvector3(x: 0, y: -10.0, z: 0) scene.rootnode.addchildnode(floornode)

swift scenekit

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -