forked from kscience/visionforge
Added JSRoot full dependency
This commit is contained in:
parent
193ae96425
commit
9f80e0894b
@ -8,8 +8,10 @@ import hep.dataforge.vis.DisplayLeaf
|
|||||||
import hep.dataforge.vis.DisplayObject
|
import hep.dataforge.vis.DisplayObject
|
||||||
import hep.dataforge.vis.int
|
import hep.dataforge.vis.int
|
||||||
import hep.dataforge.vis.spatial.MeshThreeFactory
|
import hep.dataforge.vis.spatial.MeshThreeFactory
|
||||||
|
import hep.dataforge.vis.spatial.jsroot.createCubeBuffer
|
||||||
import hep.dataforge.vis.spatial.jsroot.createGeometry
|
import hep.dataforge.vis.spatial.jsroot.createGeometry
|
||||||
import hep.dataforge.vis.spatial.jsroot.createTubeBuffer
|
import hep.dataforge.vis.spatial.jsroot.createTubeBuffer
|
||||||
|
import hep.dataforge.vis.spatial.jsroot.createXtruBuffer
|
||||||
import info.laht.threekt.core.BufferGeometry
|
import info.laht.threekt.core.BufferGeometry
|
||||||
|
|
||||||
|
|
||||||
@ -36,7 +38,7 @@ object ThreeGDMLFactory : MeshThreeFactory<GDMLShape>(GDMLShape::class) {
|
|||||||
|
|
||||||
override fun buildGeometry(obj: GDMLShape): BufferGeometry {
|
override fun buildGeometry(obj: GDMLShape): BufferGeometry {
|
||||||
return when (obj.shape) {
|
return when (obj.shape) {
|
||||||
is GDMLBox -> createTubeBuffer(
|
is GDMLBox -> createCubeBuffer(
|
||||||
obj.shape.config.toJsRoot()?.toDynamic(),
|
obj.shape.config.toJsRoot()?.toDynamic(),
|
||||||
obj.facesLimit
|
obj.facesLimit
|
||||||
)
|
)
|
||||||
@ -46,7 +48,6 @@ object ThreeGDMLFactory : MeshThreeFactory<GDMLShape>(GDMLShape::class) {
|
|||||||
)
|
)
|
||||||
is GDMLXtru -> {
|
is GDMLXtru -> {
|
||||||
val meta = buildMeta {
|
val meta = buildMeta {
|
||||||
"_typename" to "TGeoXtru"
|
|
||||||
val vertices = obj.shape.verteces
|
val vertices = obj.shape.verteces
|
||||||
val zs = obj.shape.sections.sortedBy { it.zOrder!! }
|
val zs = obj.shape.sections.sortedBy { it.zOrder!! }
|
||||||
"fNz" to zs.size
|
"fNz" to zs.size
|
||||||
@ -58,7 +59,7 @@ object ThreeGDMLFactory : MeshThreeFactory<GDMLShape>(GDMLShape::class) {
|
|||||||
"fZ" to zs.map { it.zPosition!! }
|
"fZ" to zs.map { it.zPosition!! }
|
||||||
"fScale" to zs.map { it.scalingFactor }
|
"fScale" to zs.map { it.scalingFactor }
|
||||||
}
|
}
|
||||||
createGeometry(meta.toDynamic(), obj.facesLimit)
|
createXtruBuffer(meta.toDynamic(), obj.facesLimit)
|
||||||
}
|
}
|
||||||
is GDMLUnion -> {
|
is GDMLUnion -> {
|
||||||
val meta = buildMeta {
|
val meta = buildMeta {
|
||||||
|
@ -0,0 +1,6 @@
|
|||||||
|
@file:JsModule("JSRootCore.js")
|
||||||
|
@file:JsNonModule
|
||||||
|
|
||||||
|
package hep.dataforge.vis.spatial.jsroot
|
||||||
|
|
||||||
|
external fun parse(obj: String): dynamic
|
@ -3,7 +3,6 @@ package hep.dataforge.vis.spatial.jsroot
|
|||||||
import hep.dataforge.context.Global
|
import hep.dataforge.context.Global
|
||||||
import hep.dataforge.meta.EmptyMeta
|
import hep.dataforge.meta.EmptyMeta
|
||||||
import hep.dataforge.vis.ApplicationBase
|
import hep.dataforge.vis.ApplicationBase
|
||||||
import hep.dataforge.vis.require
|
|
||||||
import hep.dataforge.vis.spatial.ThreeOutput
|
import hep.dataforge.vis.spatial.ThreeOutput
|
||||||
import hep.dataforge.vis.spatial.render
|
import hep.dataforge.vis.spatial.render
|
||||||
import org.w3c.dom.HTMLDivElement
|
import org.w3c.dom.HTMLDivElement
|
||||||
@ -20,7 +19,8 @@ class JSRootDemoApp : ApplicationBase() {
|
|||||||
override val stateKeys: List<String> = emptyList()
|
override val stateKeys: List<String> = emptyList()
|
||||||
|
|
||||||
override fun start(state: Map<String, Any>) {
|
override fun start(state: Map<String, Any>) {
|
||||||
require("JSRootGeoBase.js")
|
// require("JSRootGeoBase.js")
|
||||||
|
// require("JSRootCore.js")
|
||||||
|
|
||||||
|
|
||||||
//TODO remove after DI fix
|
//TODO remove after DI fix
|
||||||
@ -68,9 +68,8 @@ class JSRootDemoApp : ApplicationBase() {
|
|||||||
println("started")
|
println("started")
|
||||||
|
|
||||||
renderer.render {
|
renderer.render {
|
||||||
val json = JSON.parse<Any>(string).asDynamic()
|
val json = parse(string)
|
||||||
val obj = json.fVolumes.arr[0]
|
JSRootObject(this, EmptyMeta, json).also { addChild(it) }
|
||||||
JSRootObject(this, EmptyMeta, obj).also { addChild(it) }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
readAsText(file)
|
readAsText(file)
|
||||||
|
@ -15,5 +15,3 @@ external fun createTubeBuffer(shape: dynamic, limit: Int): BufferGeometry
|
|||||||
external fun createXtruBuffer(shape: dynamic, limit: Int): BufferGeometry
|
external fun createXtruBuffer(shape: dynamic, limit: Int): BufferGeometry
|
||||||
|
|
||||||
external fun build(obj: dynamic, opt: dynamic): Object3D
|
external fun build(obj: dynamic, opt: dynamic): Object3D
|
||||||
|
|
||||||
external fun buildFromJson(obj:dynamic, opt: dynamic): Object3D
|
|
||||||
|
@ -24,7 +24,7 @@ object ThreeJSRootObjectFactory : ThreeFactory<JSRootObject> {
|
|||||||
override val type = JSRootObject::class
|
override val type = JSRootObject::class
|
||||||
|
|
||||||
override fun invoke(obj: JSRootObject): Object3D {
|
override fun invoke(obj: JSRootObject): Object3D {
|
||||||
return buildFromJson(obj.data, obj.options?.toDynamic())
|
return build(obj.data, obj.options?.toDynamic())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,7 +4,12 @@
|
|||||||
} else if (typeof exports === 'object' && typeof module !== 'undefined') {
|
} else if (typeof exports === 'object' && typeof module !== 'undefined') {
|
||||||
factory(exports);
|
factory(exports);
|
||||||
} else {
|
} else {
|
||||||
JSROOT = factory();
|
if (typeof JSROOT != 'undefined')
|
||||||
|
throw new Error("JSROOT is already defined", "JSRootCore.js");
|
||||||
|
|
||||||
|
JSROOT = {};
|
||||||
|
|
||||||
|
factory(JSROOT);
|
||||||
}
|
}
|
||||||
}(function (JSROOT) {
|
}(function (JSROOT) {
|
||||||
"use strict";
|
"use strict";
|
||||||
@ -479,7 +484,7 @@
|
|||||||
*/
|
*/
|
||||||
JSROOT.parse = function (json) {
|
JSROOT.parse = function (json) {
|
||||||
if (!json) return null;
|
if (!json) return null;
|
||||||
var obj = JSON.parse(json);
|
let obj = JSON.parse(json);
|
||||||
if (obj) obj = this.JSONR_unref(obj);
|
if (obj) obj = this.JSONR_unref(obj);
|
||||||
return obj;
|
return obj;
|
||||||
};
|
};
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user