how to convert HtmlElement to HtmlTag? #310
-
hi all. I am a beginner in functional programming. I have a question. this is my code def renderWebGL(): Resource[IO, HtmlElement[IO]] = {
val webglCanvans: Resource[IO, HtmlCanvasElement[IO]] = Resource
.eval(
IO {
val sw = window.screen.width
val sh = window.screen.height
val scene = Scene()
val camera = PerspectiveCamera(75, sw / sh, 0.1, 1000)
camera.position.z = 5
// add object
val geometry =
BoxGeometry(
1,
1,
1,
js.undefined,
js.undefined,
js.undefined
)
val material =
MeshBasicMaterial.apply(
MeshBasicMaterialParameters.apply().setColor(0xff000)
)
val mesh = Mesh(geometry, material)
val cube = mesh.asInstanceOf[Object3D[Object3DEventMap]]
scene.add(cube)
// add light
val light = DirectionalLight(0xffffff, 0.5)
light.position.set(0, 0, 5)
scene.add(light)
val renderer = new WebGLRenderer()
renderer.setSize(sw, sh)
renderer.render(scene, camera)
val canvas = renderer.domElement
canvas.asInstanceOf[HtmlCanvasElement[IO]]
}
)
div(
webglCanvans(
cls := "w-[100%] h-[100%]"
),
div(
cls := " bg-red-800 w-[100px] h-[100px] left-[50px] top-[50px] z-10 absolute"
)
)
} and i found this error
it seem i should use div(
webglCanvans,
div(
cls := " bg-red-800 w-[100px] h-[100px] left-[50px] top-[50px] z-10 absolute"
)
)
} but i want to add classname in this section..... |
Beta Was this translation helpful? Give feedback.
Answered by
armanbilge
Sep 28, 2023
Replies: 1 comment 1 reply
-
Try like this: webglCanvans.flatTap(_.modify(cls := "w-[100%] h-[100%]")) You cannot convert an |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
cyz1901
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Try like this:
You cannot convert an
HtmlElement
to anHtmlTag
, so instead themodify
syntax is used to modify it post-facto.calico/calico/src/main/scala/calico/syntax.scala
Line 36 in 0ef4f21