Please,
I can this javascript code
var scene = new THREE.Scene();
using in nim js. Defing type
type
THREE* = ref THREEObj
THREEObj {.importc.} = object
Scene* {.importc.}: proc(): void
{.push importcpp.}
# var scene = new THREE.Scene();
var scene = THREE.Scene()
Error: object constructor needs an object type
Why create constructor?
thanks
OK,
Im considering that jsffi is good way.
var scene = jsnew(Scene())
var geometry = jsnew(BoxGeometry( 1, 1, 1,0,0,0 ))
will transpiled as
var scene_69011 = (new THREE.Scene());
var geometry_69079 = (new 1.0000000000000000e+00.THREE.BoxGeometry(1.0000000000000000e+00, 1.0000000000000000e+00, 0.0, 0.0, 0.0));
typeddeclaration is
proc Scene*(): JsObject {. importcpp: "THREE.Scene" .}
proc BoxGeometry*(width,
height,
depth,
widthSegments,
heightSegments,
depthSegments : float): JsObject {. importcpp: "THREE.BoxGeometry" .}
Do you know, why is constructor with parameters wrong transpiled?
thanks
From the manual :
proc cppMethod(this: CppObj, a, b, c: cint) {.importcpp: "#.CppMethod(@)".}
Produces:
x->CppMethod(1, 2, 3)
As a special rule to keep backwards compatibility with older versions of the importcpp pragma,
if there is no special pattern character (any of # ' @) at all, C++'s dot or arrow notation is assumed,
so the above example can also be written as:
proc cppMethod(this: CppObj, a, b, c: cint) {.importcpp: "CppMethod".}
The same thing is happening in your snippet.
Try using importcpp: THREE.BoxGeometry(@)
PS: I think you don't really need jsnew, you can just do importcpp: "new THREE.BoxGeometry(@)"