forked from kscience/visionforge
Group logic redone. Thee wrapper classes moved to the project
This commit is contained in:
parent
8d7eb2c1a9
commit
589afaa9b8
@ -0,0 +1,104 @@
|
||||
package hep.dataforge.vis.common
|
||||
|
||||
import hep.dataforge.meta.MetaBuilder
|
||||
import hep.dataforge.meta.MetaItem
|
||||
import hep.dataforge.names.Name
|
||||
import hep.dataforge.names.NameToken
|
||||
import hep.dataforge.names.asName
|
||||
import hep.dataforge.names.isEmpty
|
||||
import kotlinx.serialization.Transient
|
||||
|
||||
|
||||
/**
|
||||
* Abstract implementation of group of [VisualObject]
|
||||
*/
|
||||
abstract class AbstractVisualGroup : AbstractVisualObject(), VisualGroup {
|
||||
|
||||
//protected abstract val _children: MutableMap<NameToken, T>
|
||||
|
||||
/**
|
||||
* A map of top level named children
|
||||
*/
|
||||
abstract override val children: Map<NameToken, VisualObject> //get() = _children
|
||||
|
||||
override fun propertyChanged(name: Name, before: MetaItem<*>?, after: MetaItem<*>?) {
|
||||
super.propertyChanged(name, before, after)
|
||||
forEach {
|
||||
it.propertyChanged(name, before, after)
|
||||
}
|
||||
}
|
||||
|
||||
private data class Listener(val owner: Any?, val callback: (Name, VisualObject?) -> Unit)
|
||||
|
||||
@Transient
|
||||
private val listeners = HashSet<Listener>()
|
||||
|
||||
/**
|
||||
* Add listener for children change
|
||||
*/
|
||||
override fun onChildrenChange(owner: Any?, action: (Name, VisualObject?) -> Unit) {
|
||||
listeners.add(Listener(owner, action))
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove children change listener
|
||||
*/
|
||||
override fun removeChildrenChangeListener(owner: Any?) {
|
||||
listeners.removeAll { it.owner === owner }
|
||||
}
|
||||
|
||||
// /**
|
||||
// * Propagate children change event upwards
|
||||
// */
|
||||
// protected fun childrenChanged(name: Name, child: VisualObject?) {
|
||||
//
|
||||
// }
|
||||
|
||||
protected abstract fun removeChild(token: NameToken)
|
||||
|
||||
protected abstract fun setChild(token: NameToken, child: VisualObject?)
|
||||
|
||||
protected abstract fun createGroup(name: Name): VisualGroup
|
||||
|
||||
/**
|
||||
* Add named or unnamed child to the group. If key is [null] the child is considered unnamed. Both key and value are not
|
||||
* allowed to be null in the same time. If name is present and [child] is null, the appropriate element is removed.
|
||||
*/
|
||||
override fun set(name: Name, child: VisualObject?) {
|
||||
when {
|
||||
name.isEmpty() -> error("")
|
||||
name.length == 1 -> {
|
||||
val token = name.first()!!
|
||||
if (child == null) {
|
||||
removeChild(token)
|
||||
} else {
|
||||
if (child.parent == null) {
|
||||
child.parent = this
|
||||
} else {
|
||||
error("Can't reassign existing parent for $child")
|
||||
}
|
||||
setChild(token, child)
|
||||
}
|
||||
}
|
||||
else -> {
|
||||
//TODO add safety check
|
||||
val parent = (get(name.cutLast()) as? VisualGroup) ?: createGroup(name.cutLast())
|
||||
parent[name.last()!!.asName()] = child
|
||||
}
|
||||
}
|
||||
listeners.forEach { it.callback(name, child) }
|
||||
}
|
||||
|
||||
operator fun set(key: String, child: VisualObject?) = set(key.asName(), child)
|
||||
|
||||
protected fun MetaBuilder.updateChildren() {
|
||||
//adding named children
|
||||
children.forEach {
|
||||
"children[${it.key}]" to it.value.toMeta()
|
||||
}
|
||||
}
|
||||
|
||||
override fun MetaBuilder.updateMeta() {
|
||||
updateChildren()
|
||||
}
|
||||
}
|
@ -0,0 +1,60 @@
|
||||
package hep.dataforge.vis.common
|
||||
|
||||
import hep.dataforge.meta.*
|
||||
import hep.dataforge.names.Name
|
||||
import kotlinx.serialization.Transient
|
||||
|
||||
internal data class PropertyListener(
|
||||
val owner: Any? = null,
|
||||
val action: (name: Name, oldItem: MetaItem<*>?, newItem: MetaItem<*>?) -> Unit
|
||||
)
|
||||
|
||||
abstract class AbstractVisualObject : VisualObject {
|
||||
|
||||
@Transient
|
||||
override var parent: VisualObject? = null
|
||||
|
||||
@Transient
|
||||
private val listeners = HashSet<PropertyListener>()
|
||||
|
||||
override fun propertyChanged(name: Name, before: MetaItem<*>?, after: MetaItem<*>?) {
|
||||
for (l in listeners) {
|
||||
l.action(name, before, after)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onPropertyChange(owner: Any?, action: (Name, before: MetaItem<*>?, after: MetaItem<*>?) -> Unit) {
|
||||
listeners.add(PropertyListener(owner, action))
|
||||
}
|
||||
|
||||
override fun removeChangeListener(owner: Any?) {
|
||||
listeners.removeAll { it.owner == owner }
|
||||
}
|
||||
|
||||
abstract var properties: Config?
|
||||
override val config: Config
|
||||
get() = properties ?: Config().also { config ->
|
||||
properties = config
|
||||
config.onChange(this, ::propertyChanged)
|
||||
}
|
||||
|
||||
override fun setProperty(name: Name, value: Any?) {
|
||||
config[name] = value
|
||||
}
|
||||
|
||||
override fun getProperty(name: Name, inherit: Boolean): MetaItem<*>? {
|
||||
return if (inherit) {
|
||||
properties?.get(name) ?: parent?.getProperty(name, inherit)
|
||||
} else {
|
||||
properties?.get(name)
|
||||
}
|
||||
}
|
||||
|
||||
protected open fun MetaBuilder.updateMeta() {}
|
||||
|
||||
override fun toMeta(): Meta = buildMeta {
|
||||
"type" to this::class.simpleName
|
||||
"properties" to properties
|
||||
updateMeta()
|
||||
}
|
||||
}
|
@ -1,131 +1,53 @@
|
||||
package hep.dataforge.vis.common
|
||||
|
||||
import hep.dataforge.meta.Config
|
||||
import hep.dataforge.meta.MetaBuilder
|
||||
import hep.dataforge.meta.MetaItem
|
||||
import hep.dataforge.names.Name
|
||||
import hep.dataforge.names.toName
|
||||
import hep.dataforge.names.*
|
||||
import hep.dataforge.provider.Provider
|
||||
import kotlinx.serialization.Transient
|
||||
import kotlin.collections.set
|
||||
|
||||
open class VisualGroup<T : VisualObject> : AbstractVisualObject(), Iterable<T>, Provider {
|
||||
|
||||
protected open val namedChildren: MutableMap<Name, T> = HashMap()
|
||||
protected open val unnamedChildren: MutableList<T> = ArrayList()
|
||||
|
||||
override var properties: Config? = null
|
||||
interface VisualGroup : VisualObject, Provider, Iterable<VisualObject> {
|
||||
/**
|
||||
* A map of top level named children
|
||||
*/
|
||||
val children: Map<NameToken, VisualObject>
|
||||
|
||||
override val defaultTarget: String get() = VisualObject.TYPE
|
||||
|
||||
override fun iterator(): Iterator<T> = (namedChildren.values + unnamedChildren).iterator()
|
||||
|
||||
override fun provideTop(target: String): Map<Name, Any> {
|
||||
return when (target) {
|
||||
VisualObject.TYPE -> namedChildren
|
||||
else -> emptyMap()
|
||||
override fun provideTop(target: String): Map<Name, VisualObject> = if (target == VisualObject.TYPE) {
|
||||
children.flatMap { (key, value) ->
|
||||
val res: Map<Name, VisualObject> = if (value is VisualGroup) {
|
||||
value.provideTop(target).mapKeys { key + it.key }
|
||||
} else {
|
||||
mapOf(key.asName() to value)
|
||||
}
|
||||
res.entries
|
||||
}.associate { it.toPair() }
|
||||
} else {
|
||||
emptyMap()
|
||||
}
|
||||
|
||||
override fun propertyChanged(name: Name, before: MetaItem<*>?, after: MetaItem<*>?) {
|
||||
super.propertyChanged(name, before, after)
|
||||
forEach {
|
||||
it.propertyChanged(name, before, after)
|
||||
}
|
||||
}
|
||||
|
||||
private data class Listener<T : VisualObject>(val owner: Any?, val callback: (Name?, T?) -> Unit)
|
||||
|
||||
@Transient
|
||||
private val listeners = HashSet<Listener<T>>()
|
||||
/**
|
||||
* Iterate over children of this group
|
||||
*/
|
||||
override fun iterator(): Iterator<VisualObject> = children.values.iterator()
|
||||
|
||||
/**
|
||||
* Add listener for children change
|
||||
*/
|
||||
fun onChildrenChange(owner: Any?, action: (Name?, T?) -> Unit) {
|
||||
listeners.add(Listener(owner, action))
|
||||
}
|
||||
|
||||
fun onChildrenChange(owner: Any?, action: (Name, VisualObject?) -> Unit)
|
||||
|
||||
/**
|
||||
* Remove children change listener
|
||||
*/
|
||||
fun removeChildrenChangeListener(owner: Any?) {
|
||||
listeners.removeAll { it.owner === owner }
|
||||
}
|
||||
fun removeChildrenChangeListener(owner: Any?)
|
||||
|
||||
/**
|
||||
* Add named or unnamed child to the group. If key is [null] the child is considered unnamed. Both key and value are not
|
||||
* allowed to be null in the same time. If name is present and [child] is null, the appropriate element is removed.
|
||||
*/
|
||||
operator fun set(name: Name?, child: T?) {
|
||||
when {
|
||||
name != null -> {
|
||||
if (child == null) {
|
||||
namedChildren.remove(name)
|
||||
} else {
|
||||
if (child.parent == null) {
|
||||
child.parent = this
|
||||
} else {
|
||||
error("Can't reassign existing parent for $child")
|
||||
}
|
||||
namedChildren[name] = child
|
||||
}
|
||||
listeners.forEach { it.callback(name, child) }
|
||||
}
|
||||
child != null -> add(child)
|
||||
else -> error("Both key and child element are empty")
|
||||
operator fun get(name: Name): VisualObject? {
|
||||
return when {
|
||||
name.isEmpty() -> this
|
||||
name.length == 1 -> children[name.first()!!]
|
||||
else -> (children[name.first()!!] as? VisualGroup)?.get(name.cutFirst())
|
||||
}
|
||||
}
|
||||
|
||||
operator fun set(key: String?, child: T?) = set(key?.asName(), child)
|
||||
|
||||
/**
|
||||
* Get named child by name
|
||||
*/
|
||||
operator fun get(name: Name): T? = namedChildren[name]
|
||||
|
||||
/**
|
||||
* Get named child by string
|
||||
*/
|
||||
operator fun get(key: String): T? = namedChildren[key.toName()]
|
||||
|
||||
/**
|
||||
* Get an unnamed child
|
||||
*/
|
||||
operator fun get(index: Int): T? = unnamedChildren[index]
|
||||
|
||||
/**
|
||||
* Append unnamed child
|
||||
*/
|
||||
fun add(child: T) {
|
||||
if (child.parent == null) {
|
||||
child.parent = this
|
||||
} else {
|
||||
error("Can't reassign existing parent for $child")
|
||||
}
|
||||
unnamedChildren.add(child)
|
||||
listeners.forEach { it.callback(null, child) }
|
||||
operator fun set(name: Name, child: VisualObject?)
|
||||
}
|
||||
|
||||
/**
|
||||
* remove unnamed child
|
||||
*/
|
||||
fun remove(child: VisualObject) {
|
||||
unnamedChildren.remove(child)
|
||||
listeners.forEach { it.callback(null, null) }
|
||||
}
|
||||
|
||||
protected fun MetaBuilder.updateChildren() {
|
||||
//adding unnamed children
|
||||
"unnamedChildren" to unnamedChildren.map { it.toMeta() }
|
||||
//adding named children
|
||||
namedChildren.forEach {
|
||||
"children[${it.key}]" to it.value.toMeta()
|
||||
}
|
||||
}
|
||||
|
||||
override fun MetaBuilder.updateMeta() {
|
||||
updateChildren()
|
||||
}
|
||||
}
|
||||
operator fun VisualGroup.get(str: String) = get(str.toName())
|
@ -54,57 +54,3 @@ interface VisualObject : MetaRepr, Configurable {
|
||||
}
|
||||
}
|
||||
|
||||
internal data class MetaListener(
|
||||
val owner: Any? = null,
|
||||
val action: (name: Name, oldItem: MetaItem<*>?, newItem: MetaItem<*>?) -> Unit
|
||||
)
|
||||
|
||||
abstract class AbstractVisualObject: VisualObject {
|
||||
|
||||
@Transient
|
||||
override var parent: VisualObject? = null
|
||||
|
||||
@Transient
|
||||
private val listeners = HashSet<MetaListener>()
|
||||
|
||||
override fun propertyChanged(name: Name, before: MetaItem<*>?, after: MetaItem<*>?) {
|
||||
for (l in listeners) {
|
||||
l.action(name, before, after)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onPropertyChange(owner: Any?, action: (Name, before: MetaItem<*>?, after: MetaItem<*>?) -> Unit) {
|
||||
listeners.add(MetaListener(owner, action))
|
||||
}
|
||||
|
||||
override fun removeChangeListener(owner: Any?) {
|
||||
listeners.removeAll { it.owner == owner }
|
||||
}
|
||||
|
||||
abstract var properties: Config?
|
||||
override val config: Config
|
||||
get() = properties ?: Config().also { config ->
|
||||
properties = config
|
||||
config.onChange(this, ::propertyChanged)
|
||||
}
|
||||
|
||||
override fun setProperty(name: Name, value: Any?) {
|
||||
config[name] = value
|
||||
}
|
||||
|
||||
override fun getProperty(name: Name, inherit: Boolean): MetaItem<*>? {
|
||||
return if (inherit) {
|
||||
properties?.get(name) ?: parent?.getProperty(name, inherit)
|
||||
} else {
|
||||
properties?.get(name)
|
||||
}
|
||||
}
|
||||
|
||||
protected open fun MetaBuilder.updateMeta() {}
|
||||
|
||||
override fun toMeta(): Meta = buildMeta {
|
||||
"type" to this::class.simpleName
|
||||
"properties" to properties
|
||||
updateMeta()
|
||||
}
|
||||
}
|
@ -1,6 +1,7 @@
|
||||
package hep.dataforge.vis.common
|
||||
|
||||
import hep.dataforge.meta.*
|
||||
import hep.dataforge.names.EmptyName
|
||||
import hep.dataforge.names.Name
|
||||
import hep.dataforge.names.NameToken
|
||||
import hep.dataforge.names.asName
|
||||
@ -10,7 +11,7 @@ import kotlin.properties.ReadOnlyProperty
|
||||
import kotlin.properties.ReadWriteProperty
|
||||
import kotlin.reflect.KProperty
|
||||
|
||||
fun String.asName() = NameToken(this).asName()
|
||||
fun String.asName() = if (isBlank()) EmptyName else NameToken(this).asName()
|
||||
|
||||
/**
|
||||
* A delegate for display object properties
|
||||
@ -110,7 +111,11 @@ fun VisualObject.int(default: Int, key: String? = null, inherited: Boolean = fal
|
||||
|
||||
|
||||
inline fun <reified E : Enum<E>> VisualObject.enum(default: E, key: String? = null, inherited: Boolean = false) =
|
||||
DisplayObjectDelegateWrapper(key?.let{ NameToken(it).asName()}, default, inherited) { item -> item.string?.let { enumValueOf<E>(it) } }
|
||||
DisplayObjectDelegateWrapper(
|
||||
key?.let { NameToken(it).asName() },
|
||||
default,
|
||||
inherited
|
||||
) { item -> item.string?.let { enumValueOf<E>(it) } }
|
||||
|
||||
//merge properties
|
||||
|
||||
|
@ -27,7 +27,6 @@ kotlin {
|
||||
}
|
||||
jsMain{
|
||||
dependencies {
|
||||
api("info.laht.threekt:threejs-wrapper:0.106-npm-3")
|
||||
implementation(npm("three", "0.106.2"))
|
||||
implementation(npm("@hi-level/three-csg", "1.0.6"))
|
||||
implementation(npm("style-loader"))
|
||||
|
@ -76,6 +76,6 @@ inline fun VisualGroup3D.box(
|
||||
xSize: Number,
|
||||
ySize: Number,
|
||||
zSize: Number,
|
||||
name: String? = null,
|
||||
name: String = "",
|
||||
action: Box.() -> Unit = {}
|
||||
) = Box(xSize.toFloat(), ySize.toFloat(), zSize.toFloat()).apply(action).also { set(name, it) }
|
@ -39,7 +39,7 @@ class Composite(
|
||||
|
||||
inline fun VisualGroup3D.composite(
|
||||
type: CompositeType,
|
||||
name: String? = null,
|
||||
name: String = "",
|
||||
builder: VisualGroup3D.() -> Unit
|
||||
): Composite {
|
||||
val group = VisualGroup3D().apply(builder)
|
||||
@ -57,11 +57,11 @@ inline fun VisualGroup3D.composite(
|
||||
}
|
||||
}
|
||||
|
||||
fun VisualGroup3D.union(name: String? = null, builder: VisualGroup3D.() -> Unit) =
|
||||
fun VisualGroup3D.union(name: String = "", builder: VisualGroup3D.() -> Unit) =
|
||||
composite(CompositeType.UNION, name, builder = builder)
|
||||
|
||||
fun VisualGroup3D.subtract(name: String? = null, builder: VisualGroup3D.() -> Unit) =
|
||||
fun VisualGroup3D.subtract(name: String = "", builder: VisualGroup3D.() -> Unit) =
|
||||
composite(CompositeType.SUBTRACT, name, builder = builder)
|
||||
|
||||
fun VisualGroup3D.intersect(name: String? = null, builder: VisualGroup3D.() -> Unit) =
|
||||
fun VisualGroup3D.intersect(name: String = "", builder: VisualGroup3D.() -> Unit) =
|
||||
composite(CompositeType.INTERSECT, name, builder = builder)
|
@ -31,7 +31,7 @@ class ConeSegment(
|
||||
inline fun VisualGroup3D.cylinder(
|
||||
r: Number,
|
||||
height: Number,
|
||||
name: String? = null,
|
||||
name: String = "",
|
||||
block: ConeSegment.() -> Unit = {}
|
||||
): ConeSegment = ConeSegment(
|
||||
r.toFloat(),
|
||||
|
@ -31,7 +31,7 @@ class Convex(val points: List<Point3D>) : AbstractVisualObject(), VisualObject3D
|
||||
}
|
||||
}
|
||||
|
||||
inline fun VisualGroup3D.convex(name: String? = null, action: ConvexBuilder.() -> Unit = {}) =
|
||||
inline fun VisualGroup3D.convex(name: String = "", action: ConvexBuilder.() -> Unit = {}) =
|
||||
ConvexBuilder().apply(action).build().also { set(name, it) }
|
||||
|
||||
class ConvexBuilder {
|
||||
|
@ -110,5 +110,5 @@ class Extruded(
|
||||
}
|
||||
}
|
||||
|
||||
fun VisualGroup3D.extrude(name: String? = null, action: Extruded.() -> Unit = {}) =
|
||||
fun VisualGroup3D.extrude(name: String = "", action: Extruded.() -> Unit = {}) =
|
||||
Extruded().apply(action).also { set(name, it) }
|
@ -58,6 +58,6 @@ class Proxy(val templateName: Name) : AbstractVisualObject(), VisualObject3D {
|
||||
|
||||
inline fun VisualGroup3D.ref(
|
||||
templateName: Name,
|
||||
name: String? = null,
|
||||
name: String = "",
|
||||
action: Proxy.() -> Unit = {}
|
||||
) = Proxy(templateName).apply(action).also { set(name, it) }
|
@ -30,7 +30,7 @@ inline fun VisualGroup3D.sphere(
|
||||
radius: Number,
|
||||
phi: Number = 2 * PI,
|
||||
theta: Number = PI,
|
||||
name: String? = null,
|
||||
name: String = "",
|
||||
action: Sphere.() -> Unit = {}
|
||||
) = Sphere(
|
||||
radius.toFloat(),
|
||||
|
@ -131,7 +131,7 @@ inline fun VisualGroup3D.tube(
|
||||
innerRadius: Number = 0f,
|
||||
startAngle: Number = 0f,
|
||||
angle: Number = 2 * PI,
|
||||
name: String? = null,
|
||||
name: String = "",
|
||||
block: Tube.() -> Unit = {}
|
||||
): Tube = Tube(
|
||||
r.toFloat(),
|
||||
|
@ -1,14 +1,13 @@
|
||||
@file:UseSerializers(Point3DSerializer::class, NameSerializer::class)
|
||||
@file:UseSerializers(Point3DSerializer::class, NameSerializer::class, NameTokenSerializer::class)
|
||||
|
||||
package hep.dataforge.vis.spatial
|
||||
|
||||
import hep.dataforge.io.ConfigSerializer
|
||||
import hep.dataforge.io.NameSerializer
|
||||
import hep.dataforge.meta.*
|
||||
import hep.dataforge.names.Name
|
||||
import hep.dataforge.names.plus
|
||||
import hep.dataforge.names.*
|
||||
import hep.dataforge.output.Output
|
||||
import hep.dataforge.vis.common.VisualGroup
|
||||
import hep.dataforge.vis.common.AbstractVisualGroup
|
||||
import hep.dataforge.vis.common.VisualObject
|
||||
import hep.dataforge.vis.common.asName
|
||||
import hep.dataforge.vis.spatial.VisualObject3D.Companion.DETAIL_KEY
|
||||
@ -66,7 +65,7 @@ interface VisualObject3D : VisualObject {
|
||||
}
|
||||
|
||||
@Serializable
|
||||
class VisualGroup3D : VisualGroup<VisualObject3D>(), VisualObject3D, Configurable {
|
||||
class VisualGroup3D : AbstractVisualGroup(), VisualObject3D, Configurable {
|
||||
/**
|
||||
* A container for templates visible inside this group
|
||||
*/
|
||||
@ -83,10 +82,38 @@ class VisualGroup3D : VisualGroup<VisualObject3D>(), VisualObject3D, Configurabl
|
||||
override var rotation: Point3D? = null
|
||||
override var scale: Point3D? = null
|
||||
|
||||
override val namedChildren: MutableMap<Name, VisualObject3D> = HashMap()
|
||||
override val unnamedChildren: MutableList<VisualObject3D> = ArrayList()
|
||||
private val _children = HashMap<NameToken, VisualObject>()
|
||||
override val children: Map<NameToken, VisualObject> get() = _children
|
||||
|
||||
fun getTemplate(name: Name): VisualObject3D? = templates?.get(name) ?: (parent as? VisualGroup3D)?.getTemplate(name)
|
||||
override fun removeChild(token: NameToken) {
|
||||
_children.remove(token)
|
||||
}
|
||||
|
||||
override fun setChild(token: NameToken, child: VisualObject?) {
|
||||
if (child == null) {
|
||||
_children.remove(token)
|
||||
} else {
|
||||
_children[token] = child
|
||||
}
|
||||
}
|
||||
|
||||
override fun createGroup(name: Name): VisualGroup3D {
|
||||
return when{
|
||||
name.isEmpty() -> error("Should be unreachable")
|
||||
name.length == 1 -> {
|
||||
val token = name.first()!!
|
||||
when (val current = children[token]) {
|
||||
null -> VisualGroup3D().also { setChild(token, it) }
|
||||
is VisualGroup3D -> current
|
||||
else -> error("Can't create group with name $name because it exists and not a group")
|
||||
}
|
||||
}
|
||||
else -> createGroup(name.first()!!.asName()).createGroup(name.cutFirst())
|
||||
}
|
||||
}
|
||||
|
||||
fun getTemplate(name: Name): VisualObject3D? =
|
||||
templates?.get(name) as? VisualGroup3D ?: (parent as? VisualGroup3D)?.getTemplate(name)
|
||||
|
||||
override fun MetaBuilder.updateMeta() {
|
||||
set(TEMPLATES_KEY, templates?.toMeta())
|
||||
@ -99,7 +126,7 @@ class VisualGroup3D : VisualGroup<VisualObject3D>(), VisualObject3D, Configurabl
|
||||
}
|
||||
}
|
||||
|
||||
fun VisualGroup3D.group(key: String? = null, action: VisualGroup3D.() -> Unit = {}): VisualGroup3D =
|
||||
fun VisualGroup3D.group(key: String = "", action: VisualGroup3D.() -> Unit = {}): VisualGroup3D =
|
||||
VisualGroup3D().apply(action).also { set(key, it) }
|
||||
|
||||
fun Output<VisualObject3D>.render(meta: Meta = EmptyMeta, action: VisualGroup3D.() -> Unit) =
|
||||
|
@ -1,5 +1,6 @@
|
||||
package hep.dataforge.vis.spatial
|
||||
|
||||
import hep.dataforge.names.NameToken
|
||||
import kotlinx.serialization.*
|
||||
|
||||
@Serializable
|
||||
@ -39,3 +40,6 @@ object Point2DSerializer : KSerializer<Point2D> {
|
||||
serializer.serialize(encoder, Point2DSerial(obj.x, obj.y))
|
||||
}
|
||||
}
|
||||
|
||||
@Serializer(NameToken::class)
|
||||
object NameTokenSerializer : KSerializer<NameToken>
|
@ -38,11 +38,6 @@ interface ThreeFactory<T : VisualObject3D> {
|
||||
internal fun Object3D.updatePosition(obj: VisualObject3D) {
|
||||
visible = obj.visible ?: true
|
||||
position.set(obj.x, obj.y, obj.z)
|
||||
// obj.rotation?.let{
|
||||
// rotateZ(it.z)
|
||||
// rotateX(it.x)
|
||||
// rotateY(it.y)
|
||||
// }
|
||||
setRotationFromEuler(obj.euler)
|
||||
scale.set(obj.scaleX, obj.scaleY, obj.scaleZ)
|
||||
updateMatrix()
|
||||
|
@ -37,16 +37,25 @@ class ThreePlugin : AbstractPlugin() {
|
||||
|
||||
fun buildObject3D(obj: VisualObject3D): Object3D {
|
||||
return when (obj) {
|
||||
is VisualGroup3D -> Group(obj.mapNotNull {
|
||||
is VisualGroup3D -> {
|
||||
val group = info.laht.threekt.objects.Group()
|
||||
obj.children.forEach { (name, child) ->
|
||||
if (child is VisualObject3D) {
|
||||
try {
|
||||
buildObject3D(it)
|
||||
val object3D = buildObject3D(child)
|
||||
object3D.name = name.toString()
|
||||
group.add(object3D)
|
||||
} catch (ex: Throwable) {
|
||||
console.error(ex)
|
||||
logger.error(ex) { "Failed to render $it" }
|
||||
null
|
||||
logger.error(ex) { "Failed to render $name" }
|
||||
}
|
||||
}).apply {
|
||||
}
|
||||
}
|
||||
|
||||
group.apply {
|
||||
updatePosition(obj)
|
||||
//obj.onChildrenChange()
|
||||
}
|
||||
}
|
||||
is Composite -> compositeFactory(obj)
|
||||
is Proxy -> proxyFactory(obj)
|
||||
|
@ -0,0 +1,156 @@
|
||||
/*
|
||||
* The MIT License
|
||||
*
|
||||
* Copyright 2017-2018 Lars Ivar Hatledal
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
@file:JsModule("three")
|
||||
@file:JsNonModule
|
||||
|
||||
package info.laht.threekt
|
||||
|
||||
|
||||
external val REVISION: String
|
||||
external val CullFaceNone: Int
|
||||
external val CullFaceBack: Int
|
||||
external val CullFaceFront: Int
|
||||
external val CullFaceFrontBack: Int
|
||||
external val FrontFaceDirectionCW: Int
|
||||
external val FrontFaceDirectionCCW: Int
|
||||
external val BasicShadowMap: Int
|
||||
external val PCFShadowMap: Int
|
||||
external val PCFSoftShadowMap: Int
|
||||
external val FrontSide: Int
|
||||
external val BackSide: Int
|
||||
external val DoubleSide: Int
|
||||
external val FlatShading: Int
|
||||
external val SmoothShading: Int
|
||||
external val NoColors: Int
|
||||
external val FaceColors: Int
|
||||
external val VertexColors: Int
|
||||
external val NoBlending: Int
|
||||
external val NormalBlending: Int
|
||||
external val AdditiveBlending: Int
|
||||
external val SubtractiveBlending: Int
|
||||
external val MultiplyBlending: Int
|
||||
external val CustomBlending: Int
|
||||
external val AddEquation: Int
|
||||
external val SubtractEquation: Int
|
||||
external val ReverseSubtractEquation: Int
|
||||
external val MinEquation: Int
|
||||
external val MaxEquation: Int
|
||||
external val ZeroFactor: Int
|
||||
external val OneFactor: Int
|
||||
external val SrcColorFactor: Int
|
||||
external val OneMinusSrcColorFactor: Int
|
||||
external val SrcAlphaFactor: Int
|
||||
external val OneMinusSrcAlphaFactor: Int
|
||||
external val DstAlphaFactor: Int
|
||||
external val OneMinusDstAlphaFactor: Int
|
||||
external val DstColorFactor: Int
|
||||
external val OneMinusDstColorFactor: Int
|
||||
external val SrcAlphaSaturateFactor: Int
|
||||
external val NeverDepth: Int
|
||||
external val AlwaysDepth: Int
|
||||
external val LessDepth: Int
|
||||
external val LessEqualDepth: Int
|
||||
external val EqualDepth: Int
|
||||
external val GreaterEqualDepth: Int
|
||||
external val GreaterDepth: Int
|
||||
external val NotEqualDepth: Int
|
||||
external val MultiplyOperation: Int
|
||||
external val MixOperation: Int
|
||||
external val AddOperation: Int
|
||||
external val NoToneMapping: Int
|
||||
external val LinearToneMapping: Int
|
||||
external val ReinhardToneMapping: Int
|
||||
external val Uncharted2ToneMapping: Int
|
||||
external val CineonToneMapping: Int
|
||||
external val UVMapping: Int
|
||||
external val CubeReflectionMapping: Int
|
||||
external val CubeRefractionMapping: Int
|
||||
external val EquirectangularReflectionMapping: Int
|
||||
external val EquirectangularRefractionMapping: Int
|
||||
external val SphericalReflectionMapping: Int
|
||||
external val CubeUVReflectionMapping: Int
|
||||
external val CubeUVRefractionMapping: Int
|
||||
external val RepeatWrapping: Int
|
||||
external val ClampToEdgeWrapping: Int
|
||||
external val MirroredRepeatWrapping: Int
|
||||
external val NearestFilter: Int
|
||||
external val NearestMipMapNearestFilter: Int
|
||||
external val NearestMipMapLinearFilter: Int
|
||||
external val LinearFilter: Int
|
||||
external val LinearMipMapNearestFilter: Int
|
||||
external val LinearMipMapLinearFilter: Int
|
||||
external val UnsignedByteType: Int
|
||||
external val ByteType: Int
|
||||
external val ShortType: Int
|
||||
external val UnsignedShortType: Int
|
||||
external val IntType: Int
|
||||
external val UnsignedIntType: Int
|
||||
external val FloatType: Int
|
||||
external val HalfFloatType: Int
|
||||
external val UnsignedShort4444Type: Int
|
||||
external val UnsignedShort5551Type: Int
|
||||
external val UnsignedShort565Type: Int
|
||||
external val UnsignedInt248Type: Int
|
||||
external val AlphaFormat: Int
|
||||
external val RGBFormat: Int
|
||||
external val RGBAFormat: Int
|
||||
external val LuminanceFormat: Int
|
||||
external val LuminanceAlphaFormat: Int
|
||||
external val RGBEFormat: Int
|
||||
external val DepthFormat: Int
|
||||
external val DepthStencilFormat: Int
|
||||
external val RGB_S3TC_DXT1_Format: Int
|
||||
external val RGBA_S3TC_DXT1_Format: Int
|
||||
external val RGBA_S3TC_DXT3_Format: Int
|
||||
external val RGBA_S3TC_DXT5_Format: Int
|
||||
external val RGB_PVRTC_4BPPV1_Format: Int
|
||||
external val RGB_PVRTC_2BPPV1_Format: Int
|
||||
external val RGBA_PVRTC_4BPPV1_Format: Int
|
||||
external val RGBA_PVRTC_2BPPV1_Format: Int
|
||||
external val RGB_ETC1_Format: Int
|
||||
external val LoopOnce: Int
|
||||
external val LoopRepeat: Int
|
||||
external val LoopPingPong: Int
|
||||
external val InterpolateDiscrete: Int
|
||||
external val InterpolateLinear: Int
|
||||
external val InterpolateSmooth: Int
|
||||
external val ZeroCurvatureEnding: Int
|
||||
external val ZeroSlopeEnding: Int
|
||||
external val WrapAroundEnding: Int
|
||||
external val TrianglesDrawMode: Int
|
||||
external val TriangleStripDrawMode: Int
|
||||
external val TriangleFanDrawMode: Int
|
||||
external val LinearEncoding: Int
|
||||
external val sRGBEncoding: Int
|
||||
external val GammaEncoding: Int
|
||||
external val RGBEEncoding: Int
|
||||
external val LogLuvEncoding: Int
|
||||
external val RGBM7Encoding: Int
|
||||
external val RGBM16Encoding: Int
|
||||
external val RGBDEncoding: Int
|
||||
external val BasicDepthPacking: Int
|
||||
external val RGBADepthPacking: Int
|
||||
|
||||
|
@ -0,0 +1,128 @@
|
||||
@file:JsModule("three")
|
||||
@file:JsNonModule
|
||||
|
||||
package info.laht.threekt.animation
|
||||
|
||||
import info.laht.threekt.core.Object3D
|
||||
|
||||
external class AnimationAction(
|
||||
mixer: AnimationMixer,
|
||||
clip: AnimationClip,
|
||||
localRoot: Object3D
|
||||
) {
|
||||
|
||||
/**
|
||||
* Setting enabled to false disables this action, so that it has no impact. Default is true.
|
||||
*
|
||||
* When the action is re-enabled, the animation continues from its current time
|
||||
* (setting enabled to false doesn't reset the action).
|
||||
*
|
||||
* Note: Setting enabled to true doesn’t automatically restart the animation.
|
||||
* Setting enabled to true will only restart the animation immediately if the following condition
|
||||
* is fulfilled: paused is false, this action has not been deactivated in the meantime
|
||||
* (by executing a stop or reset command), and neither weight nor timeScale is 0.
|
||||
*/
|
||||
var enabled: Boolean
|
||||
|
||||
/**
|
||||
* The looping mode (can be changed with setLoop). Default is THREE.LoopRepeat (with an infinite number of repetitions)
|
||||
*/
|
||||
var loop: Int
|
||||
|
||||
/**
|
||||
* Setting paused to true pauses the execution of the action by setting the effective time scale to 0. Default is false.
|
||||
*/
|
||||
var paused: Boolean
|
||||
|
||||
var repetitions: Int
|
||||
|
||||
var time: Double
|
||||
|
||||
var timeScale: Double
|
||||
|
||||
/**
|
||||
* The degree of influence of this action (in the interval [0, 1]).
|
||||
* Values between 0 (no impact) and 1 (full impact) can be used to blend between several actions. Default is 1.
|
||||
*
|
||||
* Properties/methods concerning weight are: crossFadeFrom, crossFadeTo, enabled, fadeIn, fadeOut,
|
||||
* getEffectiveWeight, setEffectiveWeight, stopFading.
|
||||
*/
|
||||
var weight: Double
|
||||
|
||||
/**
|
||||
* Enables smooth interpolation without separate clips for start, loop and end. Default is true.
|
||||
*/
|
||||
var zeroSlopeAtEnd: Boolean
|
||||
|
||||
/**
|
||||
* Enables smooth interpolation without separate clips for start, loop and end. Default is true.
|
||||
*/
|
||||
var zeroSlopeAtStart: Boolean
|
||||
|
||||
|
||||
// State & Scheduling
|
||||
|
||||
fun play(): AnimationAction
|
||||
|
||||
fun stop(): AnimationAction
|
||||
|
||||
fun reset(): AnimationAction
|
||||
|
||||
fun isRunning(): Boolean
|
||||
|
||||
// return true when play has been called
|
||||
fun isScheduled(): Boolean
|
||||
|
||||
fun startAt(time: Number): AnimationAction
|
||||
fun setLoop(mode: Int, repetitions: Int): AnimationAction
|
||||
|
||||
// Weight
|
||||
|
||||
// set the weight stopping any scheduled fading
|
||||
// although .enabled = false yields an effective weight of zero, this
|
||||
// method does *not* change .enabled, because it would be confusing
|
||||
fun setEffectiveWeight(weight: Number)
|
||||
|
||||
// return the weight considering fading and .enabled
|
||||
fun getEffectiveWeight()
|
||||
|
||||
fun fadeIn(duration: Number): AnimationAction
|
||||
|
||||
fun fadeOut(duration: Number): AnimationAction
|
||||
|
||||
fun crossFadeFrom(fadeOutAction: AnimationAction, duration: Number, warp: Boolean)
|
||||
|
||||
fun crossFadeTo(fadeInAction: AnimationAction, duration: Number, warp: Boolean)
|
||||
|
||||
fun stopFading(): AnimationAction
|
||||
|
||||
// Time Scale Control
|
||||
|
||||
// set the time scale stopping any scheduled warping
|
||||
// although .paused = true yields an effective time scale of zero, this
|
||||
// method does *not* change .paused, because it would be confusing
|
||||
fun setEffectiveTimeScale(timeScale: Number): AnimationAction
|
||||
|
||||
// return the time scale considering warping and .paused
|
||||
fun getEffectiveTimeScale(): Double
|
||||
|
||||
fun setDuration(duration: Number): AnimationAction
|
||||
|
||||
fun syncWith(action: AnimationAction)
|
||||
|
||||
fun halt(duration: Number): AnimationAction
|
||||
|
||||
fun warp(startTimeScale: Number, endTimeScale: Number, duration: Number): AnimationAction
|
||||
|
||||
fun stopWarping(): AnimationAction
|
||||
|
||||
// Object Accessors
|
||||
|
||||
fun getMixer(): AnimationMixer
|
||||
|
||||
fun getClip(): AnimationClip
|
||||
|
||||
fun getRoot(): Object3D
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,53 @@
|
||||
@file:JsModule("three")
|
||||
@file:JsNonModule
|
||||
|
||||
package info.laht.threekt.animation
|
||||
|
||||
/**
|
||||
* An AnimationClip is a reusable set of keyframe tracks which represent an animation.
|
||||
|
||||
For an overview of the different elements of the three.js animation system see the "Animation System" article in the "Next Steps" section of the manual.
|
||||
*
|
||||
* @param name a name for this clip.
|
||||
* @param duration the duration of this clip (in seconds). If a negative value is passed, the duration will be calculated from the passed tracks array.
|
||||
* @param tracks an array of KeyframeTracks.
|
||||
*/
|
||||
external class AnimationClip(
|
||||
name: String,
|
||||
duration: Number,
|
||||
tracks: Array<KeyFrameTrack>
|
||||
) {
|
||||
|
||||
companion object {
|
||||
/**
|
||||
* Parses the animation.hierarchy format and returns an AnimationClip.
|
||||
*/
|
||||
fun parse(json: String): AnimationClip
|
||||
|
||||
/**
|
||||
* Takes an AnimationClip and returns a JSON object.
|
||||
*/
|
||||
fun toJSON(clip: AnimationClip): dynamic
|
||||
}
|
||||
|
||||
var uuid: String
|
||||
var name: String
|
||||
var duration: Double
|
||||
var tracks: Array<KeyFrameTrack>
|
||||
|
||||
/**
|
||||
* Optimizes each track by removing equivalent sequential keys (which are common in morph target sequences).
|
||||
*/
|
||||
fun optimize(): AnimationClip
|
||||
|
||||
/**
|
||||
* Sets the duration of the clip to the duration of its longest KeyframeTrack.
|
||||
*/
|
||||
fun resetDuration()
|
||||
|
||||
/**
|
||||
* Trims all tracks to the clip's duration.
|
||||
*/
|
||||
fun trim(): AnimationClip
|
||||
|
||||
}
|
@ -0,0 +1,37 @@
|
||||
@file:JsModule("three")
|
||||
@file:JsNonModule
|
||||
|
||||
package info.laht.threekt.animation
|
||||
|
||||
import info.laht.threekt.core.Object3D
|
||||
|
||||
/**
|
||||
* The AnimationMixer is a player for animations on a particular object in the scene.
|
||||
* When multiple objects in the scene are animated independently, one AnimationMixer may be used for each object.
|
||||
|
||||
* For an overview of the different elements of the three.js animation system see the "Animation System" article
|
||||
* in the "Next Steps" section of the manual.
|
||||
*/
|
||||
external class AnimationMixer(
|
||||
root: Object3D
|
||||
) {
|
||||
|
||||
var time: Double
|
||||
var timeScale: Double
|
||||
|
||||
fun clipAction(clip: AnimationClip, optionalRoot: Object3D = definedExternally): AnimationClip
|
||||
fun existingAction(clip: AnimationClip, optionalRoot: Object3D = definedExternally): AnimationClip
|
||||
|
||||
fun getRoot(): Object3D
|
||||
|
||||
fun stopAllAction()
|
||||
|
||||
fun update(deltaTimeInSeconds: Number)
|
||||
|
||||
fun uncacheClip(clip: AnimationClip)
|
||||
|
||||
fun unchacheRoot(root: Object3D)
|
||||
|
||||
fun uncacheAction(clip: AnimationClip, optionalRoot: Object3D)
|
||||
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
@file:JsModule("three")
|
||||
@file:JsNonModule
|
||||
|
||||
package info.laht.threekt.animation
|
||||
|
||||
external object AnimationUtils {
|
||||
//TODO
|
||||
}
|
@ -0,0 +1,35 @@
|
||||
@file:JsModule("three")
|
||||
@file:JsNonModule
|
||||
|
||||
package info.laht.threekt.animation
|
||||
|
||||
import org.khronos.webgl.Float32Array
|
||||
|
||||
/**
|
||||
* @param name the identifier for the KeyframeTrack.
|
||||
* @param times an array of keyframe times, converted internally to a Float32Array.
|
||||
* @param values an array with the values related to the times array, converted internally to a Float32Array.
|
||||
* @param interpolation the type of interpolation to use. See Animation Constants for possible values. Default is InterpolateLinear.
|
||||
*/
|
||||
external class KeyFrameTrack(
|
||||
name: String,
|
||||
times: Array<Number>,
|
||||
values: Array<Number>,
|
||||
interpolation: Int
|
||||
) {
|
||||
|
||||
companion object {
|
||||
var DefaultInterpolation: Int
|
||||
}
|
||||
|
||||
var name: String
|
||||
var times: Float32Array
|
||||
var values: Float32Array
|
||||
|
||||
/**
|
||||
* Returns the interpolation type
|
||||
*/
|
||||
fun getInterpolation(): Int
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,155 @@
|
||||
@file:JsModule("three")
|
||||
@file:JsNonModule
|
||||
|
||||
package info.laht.threekt.audio
|
||||
|
||||
/**
|
||||
* Create a non-positional ( global ) audio object.
|
||||
*
|
||||
* This uses the Web Audio API.
|
||||
*/
|
||||
open external class Audio(listener: AudioListener) {
|
||||
|
||||
/**
|
||||
* Whether to start playback automatically. Default is false.
|
||||
*/
|
||||
var autoPlay: Boolean
|
||||
/**
|
||||
* The AudioContext of the listener given in the constructor.
|
||||
*/
|
||||
var context: dynamic
|
||||
/**
|
||||
* Whether the audio is currently playing. Default is empty array.
|
||||
*/
|
||||
var filters: Array<dynamic>
|
||||
/**
|
||||
* A GainNode created using AudioContext.createGain().
|
||||
*/
|
||||
var gain: dynamic
|
||||
|
||||
/**
|
||||
* Whether playback can be controlled using the play(), pause() etc. methods. Default is true.
|
||||
*/
|
||||
var hasPlaybackControl: Boolean
|
||||
/**
|
||||
* Speed of playback. Default is 1.
|
||||
*/
|
||||
var playbackRate: Double
|
||||
|
||||
/**
|
||||
* Whether the audio is currently playing.
|
||||
*/
|
||||
var isPlaying: Boolean
|
||||
|
||||
/**
|
||||
* The time at which the sound should begin to play. Same as the when paramter of AudioBufferSourceNode.start(). Default is 0.
|
||||
*/
|
||||
var startTime: Double
|
||||
|
||||
/**
|
||||
* Type of the audio source. Default is string 'empty'.
|
||||
*/
|
||||
var sourceType: String
|
||||
|
||||
/**
|
||||
* Return the gainNode.
|
||||
*/
|
||||
open fun getOutput(): dynamic
|
||||
|
||||
/**
|
||||
* Setup the source to the audioBuffer, and sets sourceType to 'audioNode'.
|
||||
* Also sets hasPlaybackControl to false.
|
||||
*/
|
||||
fun setNodeSource(audioNode: dynamic): Audio
|
||||
|
||||
/**
|
||||
* Setup the source to the audioBuffer, and sets sourceType to 'buffer'.
|
||||
* If autoplay, also starts playback.
|
||||
*/
|
||||
fun setBuffer(audioBuffer: dynamic): Audio
|
||||
|
||||
/**
|
||||
* If hasPlaybackControl is true, starts playback.
|
||||
*/
|
||||
fun play(): Audio
|
||||
|
||||
/**
|
||||
* If hasPlaybackControl is true, pauses playback.
|
||||
*/
|
||||
fun pause(): Audio
|
||||
|
||||
/**
|
||||
* If hasPlaybackControl is enabled, stops playback,
|
||||
* resets startTime to 0 and sets isPlaying to false.
|
||||
*/
|
||||
fun stop(): Audio
|
||||
|
||||
/**
|
||||
* Connect to the Audio.source. This is used internally on initialisation and when setting / removing filters.
|
||||
*/
|
||||
fun connect(): Audio
|
||||
|
||||
/**
|
||||
* Disconnect from the Audio.source. This is used internally when setting / removing filters.
|
||||
*/
|
||||
fun disconnect(): Audio
|
||||
|
||||
/**
|
||||
* Returns the filters array.
|
||||
*/
|
||||
fun getFilters(): Array<dynamic>
|
||||
|
||||
/**
|
||||
* value - arrays of filters.
|
||||
* Set the filters array to value.
|
||||
*/
|
||||
fun setFilters(value: Array<dynamic>): Audio
|
||||
|
||||
/**
|
||||
* Returns the first element of the filters array.
|
||||
*/
|
||||
fun getFilter(): dynamic
|
||||
|
||||
/**
|
||||
* Add the filter to the filters array.
|
||||
*/
|
||||
fun setFilter(filter: dynamic)
|
||||
|
||||
/**
|
||||
* If hasPlaybackControl is enabled, set the playbackRate to value.
|
||||
*/
|
||||
fun setPlaybackRate(value: Number): Double
|
||||
|
||||
/**
|
||||
* Return the value of playbackRate.
|
||||
*/
|
||||
fun getPlaybackRate(): Double
|
||||
|
||||
/**
|
||||
* Called automatically when playback finished. Sets If isPlaying to false.
|
||||
*/
|
||||
fun onEnded()
|
||||
|
||||
/**
|
||||
* Return the value of source.loop (whether playback should loop).
|
||||
*/
|
||||
fun getLoop(): Boolean
|
||||
|
||||
/**
|
||||
* Set source.loop to value.
|
||||
* @param value whether playback should loop
|
||||
*/
|
||||
fun setLoop(value: Boolean): Audio
|
||||
|
||||
/**
|
||||
* Return the current volume.
|
||||
*/
|
||||
fun getVolume(): Double
|
||||
|
||||
/**
|
||||
* Set the volume.
|
||||
* @param value the volume
|
||||
*/
|
||||
fun setVolume(value: Number): Audio
|
||||
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
@file:JsModule("three")
|
||||
@file:JsNonModule
|
||||
|
||||
package info.laht.threekt.audio
|
||||
|
||||
/**
|
||||
* This contains methods for setting up an AudioContext.
|
||||
* Used internally by the AudioListener and AudioLoader classes.
|
||||
*
|
||||
* This uses the Web Audio API.
|
||||
*/
|
||||
external object AudioContext {
|
||||
|
||||
/**
|
||||
* Return the value of the variable context in the outer scope, if defined, otherwise set it to a new AudioContext.
|
||||
*/
|
||||
fun getContext(): dynamic
|
||||
|
||||
/**
|
||||
* Set the variable context in the outer scope to value.
|
||||
*/
|
||||
fun setContext(value: dynamic)
|
||||
|
||||
}
|
@ -0,0 +1,41 @@
|
||||
@file:JsModule("three")
|
||||
@file:JsNonModule
|
||||
|
||||
package info.laht.threekt.audio
|
||||
|
||||
import info.laht.threekt.core.Object3D
|
||||
|
||||
/**
|
||||
* Create a non-positional ( global ) audio object.
|
||||
*
|
||||
* This uses the Web Audio API.
|
||||
*/
|
||||
external class AudioListener : Object3D {
|
||||
|
||||
var context: dynamic
|
||||
|
||||
/**
|
||||
* Return the gainNode.
|
||||
*/
|
||||
fun getInput(): dynamic
|
||||
|
||||
/**
|
||||
* Set the filter property to null.
|
||||
*/
|
||||
fun removeFilter()
|
||||
|
||||
/**
|
||||
* Returns the value of the filter property.
|
||||
*/
|
||||
fun getFilter(): dynamic
|
||||
|
||||
/**
|
||||
* Set the filter property to value.
|
||||
*/
|
||||
fun setFilter(value: dynamic)
|
||||
|
||||
fun getMasterVolume(): Double
|
||||
|
||||
fun setMasterVolume(value: Number)
|
||||
|
||||
}
|
@ -0,0 +1,63 @@
|
||||
@file:JsModule("three")
|
||||
@file:JsNonModule
|
||||
|
||||
package info.laht.threekt.audio
|
||||
|
||||
/**
|
||||
* Create a positional audio object.
|
||||
*
|
||||
* This uses the Web Audio API.
|
||||
*/
|
||||
external class PositionalAudio(listener: AudioListener) : Audio {
|
||||
|
||||
/**
|
||||
* The PositionalAudio's PannerNode.
|
||||
*/
|
||||
var panner: dynamic
|
||||
|
||||
/**
|
||||
* Returns the panner.
|
||||
*/
|
||||
override fun getOutput(): dynamic
|
||||
|
||||
/**
|
||||
* Returns the value of panner.refDistance.
|
||||
*/
|
||||
fun getRefDistance(): Double
|
||||
|
||||
/**
|
||||
* Sets the value of panner.refDistance.
|
||||
*/
|
||||
fun setRefDistance(value: Number)
|
||||
|
||||
/**
|
||||
* Returns the value of panner.rolloffFactor.
|
||||
*/
|
||||
fun getRolloffFactor(): Double
|
||||
|
||||
/**
|
||||
* Sets the value of panner.rolloffFactor.
|
||||
*/
|
||||
fun setRolloffFactor(value: Number)
|
||||
|
||||
/**
|
||||
* Returns the value of panner.distanceModel.
|
||||
*/
|
||||
fun getDistanceModel(): String
|
||||
|
||||
/**
|
||||
* Sets the value of panner.distanceModel.
|
||||
*/
|
||||
fun setDistanceModel(value: String)
|
||||
|
||||
/**
|
||||
* Returns the value of panner.maxDistance.
|
||||
*/
|
||||
fun getMaxDistance(): Double
|
||||
|
||||
/**
|
||||
* Sets the value of panner.maxDistance.
|
||||
*/
|
||||
fun setMaxDistance(value: Number)
|
||||
|
||||
}
|
@ -0,0 +1,87 @@
|
||||
/*
|
||||
* The MIT License
|
||||
*
|
||||
* Copyright 2017-2018 Lars Ivar Hatledal
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
@file:JsModule("three")
|
||||
@file:JsNonModule
|
||||
|
||||
package info.laht.threekt.cameras
|
||||
|
||||
import info.laht.threekt.core.Object3D
|
||||
import info.laht.threekt.math.Matrix4
|
||||
import info.laht.threekt.math.Vector3
|
||||
|
||||
external interface View {
|
||||
var enabled: Boolean
|
||||
var fullwidth: Int
|
||||
var fullHeight: Int
|
||||
var offsetX: Int
|
||||
var offsetY: Int
|
||||
var width: Int
|
||||
var height: Int
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Creates a new Camera. Note that this class is not intended to be called directly;
|
||||
* you probably want a PerspectiveCamera or OrthographicCamera instead.
|
||||
*/
|
||||
open external class Camera : Object3D {
|
||||
|
||||
|
||||
/**
|
||||
* This is the inverse of matrixWorld. MatrixWorld contains the Matrix which has the world transform of the Camera.
|
||||
*/
|
||||
var matrixWorldInverse: Matrix4
|
||||
/**
|
||||
* /**
|
||||
* This is the matrix which contains the projection.
|
||||
*/
|
||||
*/
|
||||
var projectionMatrix: Matrix4
|
||||
|
||||
|
||||
/**
|
||||
* Returns a Vector3 representing the world space direction in which the camera is looking.
|
||||
*
|
||||
* Note: This is not the camera’s positive, but its negative z-axis, in contrast to getWorldDirection of the base class (Object3D).
|
||||
*
|
||||
*/
|
||||
fun getWorldDirection(): Vector3
|
||||
|
||||
/**
|
||||
* Returns a Vector3 representing the world space direction in which the camera is looking.
|
||||
*
|
||||
* Note: This is not the camera’s positive, but its negative z-axis, in contrast to getWorldDirection of the base class (Object3D).
|
||||
*
|
||||
* If an optionalTarget vector is specified, the result will be copied into this vector (which can be reused in this way),
|
||||
* otherwise a new vector will be created.
|
||||
*/
|
||||
override fun getWorldDirection(optionalTarget: Vector3): Vector3
|
||||
|
||||
override fun updateMatrixWorld(force: Boolean)
|
||||
|
||||
fun clone(): Camera
|
||||
fun copy(source: Camera, recursive: Boolean)
|
||||
|
||||
}
|
@ -0,0 +1,57 @@
|
||||
/*
|
||||
* The MIT License
|
||||
*
|
||||
* Copyright 2017-2018 Lars Ivar Hatledal
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
@file:JsModule("three")
|
||||
@file:JsNonModule
|
||||
|
||||
package info.laht.threekt.cameras
|
||||
|
||||
external class OrthographicCamera(
|
||||
varleft: Int,
|
||||
right: Int,
|
||||
top: Int,
|
||||
bottom: Int,
|
||||
near: Number = definedExternally,
|
||||
far: Number = definedExternally
|
||||
) : Camera {
|
||||
|
||||
var zoom: Int
|
||||
var view: View
|
||||
|
||||
var left: Int
|
||||
var right: Int
|
||||
var top: Int
|
||||
var bottom: Int
|
||||
|
||||
var near: Double
|
||||
var far: Double
|
||||
|
||||
fun copy(camera: OrthographicCamera): OrthographicCamera
|
||||
|
||||
fun setViewOffset(fullwidth: Int, fullHeight: Int, x: Int, y: Int, width: Int, height: Int)
|
||||
fun clearViewOffset()
|
||||
fun updateProjectionMatrix()
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,50 @@
|
||||
/*
|
||||
* The MIT License
|
||||
*
|
||||
* Copyright 2017-2018 Lars Ivar Hatledal
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
@file:JsModule("three")
|
||||
@file:JsNonModule
|
||||
|
||||
package info.laht.threekt.cameras
|
||||
|
||||
|
||||
external class PerspectiveCamera(fov: Int, aspect: Double, near: Number, far: Number) : Camera {
|
||||
var fov: Int
|
||||
var zoom: Double
|
||||
|
||||
var near: Double
|
||||
var far: Double
|
||||
var focus: Double
|
||||
|
||||
var aspect: Double
|
||||
var view: View
|
||||
|
||||
var filmGauge: Int
|
||||
var filmOffset: Int
|
||||
|
||||
fun copy(source: PerspectiveCamera, recursive: Boolean = definedExternally)
|
||||
|
||||
fun setViewOffset(fullwidth: Int, fullHeight: Int, x: Int, y: Int, width: Int, height: Int)
|
||||
fun clearViewOffset()
|
||||
fun updateProjectionMatrix()
|
||||
}
|
@ -0,0 +1,207 @@
|
||||
/*
|
||||
* The MIT License
|
||||
*
|
||||
* Copyright 2017-2018 Lars Ivar Hatledal
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
@file:JsModule("three")
|
||||
@file:JsNonModule
|
||||
|
||||
package info.laht.threekt.core
|
||||
|
||||
import info.laht.threekt.math.Color
|
||||
import info.laht.threekt.math.Vector2
|
||||
import info.laht.threekt.math.Vector3
|
||||
import info.laht.threekt.math.Vector4
|
||||
|
||||
abstract external class BufferAttribute protected constructor(
|
||||
array: dynamic,
|
||||
itemSize: Int,
|
||||
normalized: Boolean = definedExternally
|
||||
) {
|
||||
|
||||
|
||||
interface UpdateRange {
|
||||
/**
|
||||
* Default is 0. Position at whcih to start update.
|
||||
*/
|
||||
var offset: Int
|
||||
/**
|
||||
* Default is -1, which means don't use update ranges.
|
||||
|
||||
*/
|
||||
var count: Int
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* UUID of this object instance. This gets automatically assigned and this shouldn't be edited.
|
||||
*/
|
||||
val uuid: String
|
||||
/**
|
||||
* Optional name for this attribute instance. Default is an empty string.
|
||||
*/
|
||||
var name: String
|
||||
|
||||
var array: dynamic
|
||||
/**
|
||||
* The length of vectors that are being stored in the array.
|
||||
*/
|
||||
val itemSize: Int
|
||||
/**
|
||||
* Stores the array's length divided by the itemSize.
|
||||
*
|
||||
* If the buffer is storing a 3-component vector (such as a position, normal, or color),
|
||||
* then this will count the number of such vectors stored.
|
||||
*/
|
||||
val count: Int
|
||||
/**
|
||||
* Indicates how the underlying data in the buffer maps to the values in the GLSL shader code. See the constructor above for details.
|
||||
*/
|
||||
var normalized: Boolean
|
||||
|
||||
/**
|
||||
* Whether the buffer is dynamic or not. Default is false.
|
||||
* If false, the GPU is informed that contents of the buffer are likely to be used often and not change often.
|
||||
* This corresponds to the glfun sTATIC_DRAW flag.
|
||||
* if true, the GPU is informed that contents of the buffer are likely to be used often and change often.
|
||||
* This corresponds to the gl.DYNAMIC_DRAW flag.
|
||||
*/
|
||||
var dynamic: Boolean
|
||||
/**
|
||||
* This can be used to only update some components of stored vectors (
|
||||
* for example, just the component related to color).
|
||||
*/
|
||||
var updateRange: UpdateRange
|
||||
|
||||
/**
|
||||
* Flag to indicate that this attribute has changed and should be re-sent to the GPU. Set this to true when you modify the value of the array.
|
||||
*
|
||||
* Setting this to true also increments the version.
|
||||
*/
|
||||
var needsUpdate: Boolean
|
||||
|
||||
var onUploadCallback: () -> Unit
|
||||
|
||||
/**
|
||||
* A version number, incremented every time the needsUpdate property is set to true.
|
||||
*/
|
||||
val version: Int
|
||||
|
||||
fun setArray(array: dynamic)
|
||||
|
||||
/**
|
||||
* Set dynamic to value.
|
||||
*/
|
||||
fun setDynamic(value: Boolean)
|
||||
|
||||
/**
|
||||
* Returns the w component of the vector at the given index.
|
||||
*/
|
||||
fun getW(index: Int): Number
|
||||
|
||||
fun copy(source: BufferAttribute): BufferAttribute
|
||||
/**
|
||||
* Copy a vector from bufferAttribute[index2] to array[index1].
|
||||
*/
|
||||
fun copyAt(index1: Int, attribute: BufferAttribute, index2: Int): BufferAttribute
|
||||
|
||||
/**
|
||||
* Copy an array representing Face3 indices into array.
|
||||
*/
|
||||
fun copyIndicesArray(indices: Array<Int>)
|
||||
|
||||
/**
|
||||
* Copy an array representing RGB color values into array.
|
||||
*/
|
||||
fun copyColorsArray(colors: Array<Color>)
|
||||
|
||||
/**
|
||||
* Copy an array representing Vector2s into array.
|
||||
*/
|
||||
fun copyVector2sArray(vectors: Array<Vector2>)
|
||||
|
||||
/**
|
||||
* Copy an array representing Vector3s into array.
|
||||
*/
|
||||
fun copyVector3sArray(vectors: Array<Vector3>)
|
||||
|
||||
/**
|
||||
* Copy an array representing Vector4s into array.
|
||||
*/
|
||||
fun copyVector4sArray(vectors: Array<Vector4>)
|
||||
|
||||
/**
|
||||
* Return a copy of this bufferAttribute.
|
||||
*/
|
||||
open fun clone(): BufferAttribute
|
||||
|
||||
|
||||
/**
|
||||
* Returns the x component of the vector at the given index.
|
||||
*/
|
||||
fun getX(index: Int): Number
|
||||
|
||||
/**
|
||||
* Returns the y component of the vector at the given index.
|
||||
*/
|
||||
fun getY(index: Int): Number
|
||||
|
||||
/**
|
||||
* Returns the z component of the vector at the given index.
|
||||
*/
|
||||
fun getZ(index: Int): Number
|
||||
|
||||
/**
|
||||
* Sets the x component of the vector at the given index.
|
||||
*/
|
||||
fun setX(index: Int, x: Number)
|
||||
|
||||
/**
|
||||
* Sets the y component of the vector at the given index.
|
||||
*/
|
||||
fun setY(index: Int, y: Number)
|
||||
|
||||
/**
|
||||
* Sets the z component of the vector at the given index.
|
||||
*/
|
||||
fun setZ(index: Int, z: Number)
|
||||
|
||||
/**
|
||||
* Sets the w component of the vector at the given index.
|
||||
*/
|
||||
fun setW(index: Int, w: Number)
|
||||
|
||||
/**
|
||||
* Sets the x, y component of the vector at the given index.
|
||||
*/
|
||||
fun setXY(index: Int, x: Number, y: Number)
|
||||
|
||||
/**
|
||||
* Sets the x, y, z component of the vector at the given index.
|
||||
*/
|
||||
fun setXYZ(index: Int, x: Number, y: Number, z: Number)
|
||||
|
||||
/**
|
||||
* Sets the x, y, z, w component of the vector at the given index.
|
||||
*/
|
||||
fun setXYZW(index: Int, x: Number, y: Number, z: Number, w: Number)
|
||||
}
|
@ -0,0 +1,117 @@
|
||||
/*
|
||||
* The MIT License
|
||||
*
|
||||
* Copyright 2017-2018 Lars Ivar Hatledal
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
@file:JsModule("three")
|
||||
@file:JsNonModule
|
||||
|
||||
package info.laht.threekt.core
|
||||
|
||||
import info.laht.threekt.math.Box3
|
||||
import info.laht.threekt.math.Matrix4
|
||||
import info.laht.threekt.math.Sphere
|
||||
import info.laht.threekt.math.Vector3
|
||||
|
||||
/**
|
||||
* This class is an efficient alternative to Geometry, because it stores all data, including vertex positions,
|
||||
* face indices, normals, colors, UVs, and custom attributes within buffers; this reduces the cost of passing all
|
||||
* this data to the GPU.
|
||||
* This also makes BufferGeometry harder to work with than Geometry; rather than accessing position data as Vector3
|
||||
* objects, color data as Color objects, and so on, you have to access the raw data from the appropriate attribute buffer.
|
||||
* This makes BufferGeometry best-suited for static objects where you don't need to manipulate the geometry much
|
||||
* after instantiating it.
|
||||
*/
|
||||
open external class BufferGeometry {
|
||||
|
||||
interface DrawRange {
|
||||
var start: Int
|
||||
var count: Int
|
||||
}
|
||||
|
||||
interface Group {
|
||||
var start: Int
|
||||
var count: Int
|
||||
var materialIndex: Int
|
||||
}
|
||||
|
||||
val uuid: String
|
||||
val id: String
|
||||
|
||||
var name: String
|
||||
var type: String
|
||||
|
||||
var index: dynamic
|
||||
var attributes: Map<String, BufferAttribute>
|
||||
|
||||
var morphAttributes: Map<String, BufferAttribute>
|
||||
|
||||
var groups: List<Group>
|
||||
|
||||
var boundingBox: Box3?
|
||||
var boundingSphere: Sphere?
|
||||
|
||||
var drawRange: DrawRange
|
||||
|
||||
|
||||
open fun clone(): BufferGeometry
|
||||
fun copy(bufferGeometry: BufferGeometry): BufferGeometry
|
||||
|
||||
fun computeBoundingBox()
|
||||
fun computeBoundingSphere()
|
||||
|
||||
fun center(): Vector3
|
||||
|
||||
fun dispose()
|
||||
fun clearGroups()
|
||||
fun addGroup(start: Int, count: Int, materialIndex: Int = definedExternally)
|
||||
|
||||
fun addAttribute(name: String, attribute: BufferAttribute)
|
||||
fun getAttribute(name: String): BufferAttribute
|
||||
fun removeAttribute(name: String): BufferGeometry
|
||||
|
||||
fun setIndex(index: BufferAttribute)
|
||||
fun setDrawRange(start: Int, count: Int)
|
||||
|
||||
fun fromGeometry(geometry: Geometry)
|
||||
fun setFromObject(`object`: Object3D): BufferGeometry
|
||||
fun updateFromObject(`object`: Object3D): BufferGeometry
|
||||
fun setFromPoints(points: Array<Vector3>): BufferGeometry
|
||||
fun merge(bufferGeometry: BufferGeometry, offset: Int = definedExternally): BufferGeometry
|
||||
|
||||
|
||||
fun applyMatrix(matrix: Matrix4)
|
||||
fun lookAt(vector: Vector3): BufferGeometry
|
||||
fun rotateX(radians: Double): BufferGeometry
|
||||
fun rotateY(radians: Double): BufferGeometry
|
||||
fun rotateZ(radians: Double): BufferGeometry
|
||||
fun scale(x: Double, y: Double, z: Double): BufferGeometry
|
||||
fun translate(x: Double, y: Double, z: Double): BufferGeometry
|
||||
|
||||
|
||||
fun computeVertexNormals()
|
||||
fun normalizeNormals()
|
||||
fun toNonIndexed(): BufferGeometry
|
||||
|
||||
fun toJSON(): Any
|
||||
|
||||
}
|
@ -0,0 +1,82 @@
|
||||
/*
|
||||
* The MIT License
|
||||
*
|
||||
* Copyright 2017-2018 Lars Ivar Hatledal
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
@file:JsModule("three")
|
||||
@file:JsNonModule
|
||||
|
||||
package info.laht.threekt.core
|
||||
|
||||
/**
|
||||
* Object for keeping track of time.
|
||||
* This uses performance.now() if it is available, otherwise it reverts to the less accurate Date.now().
|
||||
* @param autoStart (optional) whether to automatically start the clock. Default is true.
|
||||
*/
|
||||
external class Clock(autoStart: Boolean = definedExternally) {
|
||||
|
||||
/**
|
||||
* If set, starts the clock automatically when the first update is called. Default is true.
|
||||
*/
|
||||
var autoStart: Boolean
|
||||
|
||||
/**
|
||||
* Holds the time at which the clock's start method was last called.
|
||||
*/
|
||||
val startTime: Double
|
||||
/**
|
||||
* Holds the time at which the clock's start, getElapsedTime or getDelta methods were last called.
|
||||
*/
|
||||
val oldTime: Double
|
||||
/**
|
||||
* Keeps track of the total time that the clock has been running.
|
||||
*/
|
||||
val elapsedTime: Double
|
||||
|
||||
/**
|
||||
* Whether the clock is running or not.
|
||||
*/
|
||||
val running: Boolean
|
||||
|
||||
/**
|
||||
* Starts clock. Also sets the startTime and oldTime to the current time, sets elapsedTime to 0 and running to true.
|
||||
*/
|
||||
fun start()
|
||||
|
||||
/**
|
||||
* Stops clock and sets oldTime to the current time.
|
||||
*/
|
||||
fun stop()
|
||||
|
||||
/**
|
||||
* Get the seconds passed since the clock started and sets oldTime to the current time.
|
||||
* If autoStart is true and the clock is not running, also starts the clock.
|
||||
*/
|
||||
fun getElapsedTime(): Double
|
||||
|
||||
/**
|
||||
* Get the seconds passed since the time oldTime was set and sets oldTime to the current time.
|
||||
* If autoStart is true and the clock is not running, also starts the clock.
|
||||
*/
|
||||
fun getDelta(): Double
|
||||
|
||||
}
|
@ -0,0 +1,48 @@
|
||||
/*
|
||||
* The MIT License
|
||||
*
|
||||
* Copyright 2017-2018 Lars Ivar Hatledal
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
@file:JsModule("three")
|
||||
@file:JsNonModule
|
||||
|
||||
package info.laht.threekt.core
|
||||
|
||||
import info.laht.threekt.math.Box3
|
||||
import info.laht.threekt.math.Sphere
|
||||
|
||||
external class DirectGeometry {
|
||||
|
||||
var verticesNeedUpdate: Boolean
|
||||
var normalsNeedUpdate: Boolean
|
||||
var colorsNeedUpdate: Boolean
|
||||
var uvsNeedUpdate: Boolean
|
||||
var groupsNeedUpdate: Boolean
|
||||
|
||||
fun computeBoundingBox(): Box3
|
||||
fun computeBoundingSphere(): Sphere
|
||||
|
||||
fun dispose()
|
||||
|
||||
fun fromGeometry(geometry: Geometry)
|
||||
|
||||
}
|
@ -0,0 +1,37 @@
|
||||
/*
|
||||
* The MIT License
|
||||
*
|
||||
* Copyright 2017-2018 Lars Ivar Hatledal
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
@file:JsModule("three")
|
||||
@file:JsNonModule
|
||||
|
||||
package info.laht.threekt.core
|
||||
|
||||
external open class EventDispatcher {
|
||||
|
||||
fun addEventListener(type: String, listener: (dynamic) -> Unit)
|
||||
fun hasEventListener(type: String, listener: (dynamic) -> Unit)
|
||||
fun removeEventListener(type: String, listener: (dynamic) -> Unit)
|
||||
fun dispatchEvent(event: dynamic)
|
||||
|
||||
}
|
@ -0,0 +1,68 @@
|
||||
/*
|
||||
* The MIT License
|
||||
*
|
||||
* Copyright 2017-2018 Lars Ivar Hatledal
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
@file:JsModule("three")
|
||||
@file:JsNonModule
|
||||
|
||||
package info.laht.threekt.core
|
||||
|
||||
import info.laht.threekt.math.Color
|
||||
import info.laht.threekt.math.Vector3
|
||||
|
||||
external class Face3 {
|
||||
|
||||
constructor(
|
||||
a: Int,
|
||||
b: Int,
|
||||
c: Int,
|
||||
normal: Vector3 = definedExternally,
|
||||
color: Color = definedExternally,
|
||||
materialIndex: Int = definedExternally
|
||||
)
|
||||
|
||||
constructor(
|
||||
a: Int,
|
||||
b: Int,
|
||||
c: Int,
|
||||
normal: Array<Vector3> = definedExternally,
|
||||
color: Array<Color> = definedExternally,
|
||||
materialIndex: Int = definedExternally
|
||||
)
|
||||
|
||||
var a: Int
|
||||
var b: Int
|
||||
var c: Int
|
||||
|
||||
var normal: Vector3?
|
||||
var vertexNormals: Array<Vector3>?
|
||||
|
||||
var color: Color?
|
||||
var vertexColors: Array<Color>?
|
||||
|
||||
var materialIndex: Int?
|
||||
|
||||
fun clone(): Face3
|
||||
fun copy(source: Face3): Face3
|
||||
|
||||
}
|
@ -0,0 +1,109 @@
|
||||
/*
|
||||
* The MIT License
|
||||
*
|
||||
* Copyright 2017-2018 Lars Ivar Hatledal
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
@file:JsModule("three")
|
||||
@file:JsNonModule
|
||||
|
||||
package info.laht.threekt.core
|
||||
|
||||
import info.laht.threekt.math.*
|
||||
import info.laht.threekt.objects.Mesh
|
||||
|
||||
external interface MorphTarget {
|
||||
val name: String
|
||||
val vertices: Array<Vector3>
|
||||
}
|
||||
|
||||
external interface MorphNormal {
|
||||
val name: String
|
||||
val normals: Array<Vector3>
|
||||
}
|
||||
|
||||
open external class Geometry {
|
||||
|
||||
val id: Int
|
||||
|
||||
var vertices: Array<Vector3>
|
||||
var colors: Array<Color>
|
||||
var faces: Array<Face3>
|
||||
var faceVertexUvs: Array<Array<Vector2>>
|
||||
|
||||
var morphTargets: Array<MorphTarget>
|
||||
var morphNormals: Array<MorphNormal>
|
||||
|
||||
var skinWeights: Array<Vector4>
|
||||
var skinIndices: Array<Vector4>
|
||||
|
||||
var lineDistances: List<Double>
|
||||
|
||||
var boundingBox: Box3?
|
||||
var boundingSphere: Sphere?
|
||||
|
||||
// update flags
|
||||
|
||||
var elementsNeedUpdate: Boolean
|
||||
var verticesNeedUpdate: Boolean
|
||||
var uvsNeedUpdate: Boolean
|
||||
var normalsNeedUpdate: Boolean
|
||||
var colorsNeedUpdate: Boolean
|
||||
var lineDistancesNeedUpdate: Boolean
|
||||
var groupsNeedUpdate: Boolean
|
||||
|
||||
fun applyMatrix(matrix: Matrix4): Geometry
|
||||
fun rotateX(angle: Number): Geometry
|
||||
fun rotateY(angle: Number): Geometry
|
||||
fun rotateZ(angle: Number): Geometry
|
||||
fun translate(x: Number, y: Number, z: Number): Geometry
|
||||
fun scale(x: Number, y: Number, z: Number): Geometry
|
||||
fun lookAt(vector: Vector3): Geometry
|
||||
fun fromBufferGeometry(geometry: BufferGeometry): Geometry
|
||||
fun addFace(a: Int, b: Int, c: Int, materialIndexOffset: Int = definedExternally)
|
||||
fun center(): Vector3
|
||||
fun normalize(): Geometry
|
||||
fun computeFaceNormals()
|
||||
fun computeVertexNormals(areaWeighted: Boolean = definedExternally)
|
||||
fun computeFlatVertexNormals()
|
||||
fun computeMorphNormals()
|
||||
fun computeLineDistances()
|
||||
fun computeBoundingBox()
|
||||
fun computeBoundingSphere()
|
||||
|
||||
fun merge(geometry: Geometry, matrix: Matrix4 = definedExternally, materialIndexOffset: Int = definedExternally)
|
||||
|
||||
fun mergeMesh(mesh: Mesh)
|
||||
|
||||
fun mergeVertices()
|
||||
|
||||
fun setFromPoint(points: Array<Vector3>): Geometry
|
||||
|
||||
fun sortFacesByMaterialIndex()
|
||||
|
||||
fun toJSON(): Any
|
||||
|
||||
open fun clone(): Geometry
|
||||
fun copy(geometry: Geometry): Geometry
|
||||
|
||||
fun dispose()
|
||||
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
/*
|
||||
* The MIT License
|
||||
*
|
||||
* Copyright 2017-2018 Lars Ivar Hatledal
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
@file:JsModule("three")
|
||||
@file:JsNonModule
|
||||
|
||||
package info.laht.threekt.core
|
||||
|
||||
external class InstancedBufferGeometry : BufferGeometry {
|
||||
|
||||
var maxInstancedCount: Int?
|
||||
|
||||
fun copy(source: InstancedBufferGeometry): InstancedBufferGeometry
|
||||
|
||||
override fun clone(): InstancedBufferGeometry
|
||||
|
||||
}
|
@ -0,0 +1,75 @@
|
||||
/*
|
||||
* The MIT License
|
||||
*
|
||||
* Copyright 2017-2018 Lars Ivar Hatledal
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
@file:JsModule("three")
|
||||
@file:JsNonModule
|
||||
|
||||
package info.laht.threekt.core
|
||||
|
||||
/**
|
||||
* A Layers object assigns an Object3D to 1 or more of 32 layers numbered 0 to 31 - internally the
|
||||
* layers are stored as a bit mask, and by default all Object3Ds are a member of layer 0.
|
||||
*
|
||||
* This can be used to control visibility - an object must share a layer with a camera to be visible when that
|
||||
* camera's view is renderered.
|
||||
*
|
||||
* All classes that inherit from Object3D have an Object3D.layers property which is an instance of this class.
|
||||
*/
|
||||
external class Layers {
|
||||
|
||||
/**
|
||||
* A bit mask storing which of the 32 layers this layers object is currently a member of.
|
||||
*/
|
||||
var mask: Int
|
||||
|
||||
/**
|
||||
* Set membership to layer, and remove membership all other layers.
|
||||
* @param layer layer - an integer from 0 to 31.
|
||||
*/
|
||||
fun set(layer: Int)
|
||||
|
||||
/**
|
||||
* Add membership of this layer.
|
||||
* @param layer an integer from 0 to 31.
|
||||
*/
|
||||
fun enable(layer: Int)
|
||||
|
||||
/**
|
||||
* Toggle membership of layer.
|
||||
* @layer - an integer from 0 to 31.
|
||||
*/
|
||||
fun toggle(layer: Int)
|
||||
|
||||
/**
|
||||
* Remove membership of this layer.
|
||||
* @layer - an integer from 0 to 31.
|
||||
*/
|
||||
fun disable(layer: Int)
|
||||
|
||||
/**
|
||||
* Returns true if this and the passed layers object are members of the same set of layers.
|
||||
* @param layers a Layers object
|
||||
*/
|
||||
fun test(layers: Int)
|
||||
}
|
@ -0,0 +1,328 @@
|
||||
/*
|
||||
* The MIT License
|
||||
*
|
||||
* Copyright 2017-2018 Lars Ivar Hatledal
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
@file:JsModule("three")
|
||||
@file:JsNonModule
|
||||
|
||||
|
||||
package info.laht.threekt.core
|
||||
|
||||
import info.laht.threekt.math.*
|
||||
|
||||
/**
|
||||
* This is the base class for most objects in three.js and provides a set of properties and methods for manipulating objects in 3D space.
|
||||
*
|
||||
* Note that this can be used for grouping objects via the .add( object ) method which adds the object as a child, however it is better to use Group for this.
|
||||
*/
|
||||
open external class Object3D {
|
||||
|
||||
companion object {
|
||||
val DefaultUp: Vector3
|
||||
val DefaultMatrixAutoUpdate: Boolean
|
||||
}
|
||||
|
||||
/**
|
||||
* readonly – Unique number for this object instance.
|
||||
*/
|
||||
val id: Int
|
||||
|
||||
/**
|
||||
* UUID of this object instance. This gets automatically assigned, so this shouldn't be edited.
|
||||
*/
|
||||
val uuid: String
|
||||
|
||||
/**
|
||||
* Optional name of the object (doesn't need to be unique). Default is an empty string.
|
||||
*/
|
||||
var name: String
|
||||
|
||||
/**
|
||||
* Object's parent in the scene graph.
|
||||
*/
|
||||
val parent: Object3D?
|
||||
/**
|
||||
* Array with object's children. See Group for info on manually grouping objects.
|
||||
*/
|
||||
val children: Array<Object3D>
|
||||
|
||||
/**
|
||||
* This is used by the lookAt method, for example, to determine the orientation of the result.
|
||||
* Default is Object3D.DefaultUp - that is, ( 0, 1, 0 ).
|
||||
*/
|
||||
val up: Vector3
|
||||
|
||||
/**
|
||||
* A Vector3 representing the object's local position. Default is (0, 0, 0).
|
||||
*/
|
||||
val position: Vector3
|
||||
/**
|
||||
* Object's local rotation (see Euler angles), in radians.
|
||||
*/
|
||||
val rotation: Euler
|
||||
/**
|
||||
* Object's local rotation as a Quaternion.
|
||||
*/
|
||||
val quaternion: Quaternion
|
||||
/**
|
||||
* The object's local # .scale . Default is Vector3( 1, 1, 1 ).
|
||||
*/
|
||||
val scale: Vector3
|
||||
/**
|
||||
* This is passed to the shader and used to calculate the position of the object.
|
||||
*/
|
||||
val modelViewMatrix: Matrix4
|
||||
/**
|
||||
* This is passed to the shader and used to calculate lighting for the object.
|
||||
* It is the transpose of the inverse of the upper left 3x3 sub-matrix of this object's modelViewMatrix.
|
||||
*
|
||||
* The reason for this special matrix is that simply using the modelViewMatrix could result in a non-unit
|
||||
* length of normals (on scaling) or in a non-perpendicular direction (on non-uniform scaling).
|
||||
*
|
||||
* On the other hand the translation part of the modelViewMatrix is not relevant for the calculation of normals.
|
||||
* Thus a Matrix3 is sufficient.
|
||||
*/
|
||||
val normalMatrix: Matrix3
|
||||
|
||||
/**
|
||||
* The local transform matrix.
|
||||
*/
|
||||
var matrix: Matrix4
|
||||
/**
|
||||
* The global transform of the object. If the Object3D has no parent, then it's identical to the local transform .matrix.
|
||||
*/
|
||||
var matrixWorld: Matrix4
|
||||
|
||||
/**
|
||||
* When this is set, it calculates the matrix of position, (rotation or quaternion) and scale every frame and
|
||||
* also recalculates the matrixWorld property. Default is Object3D.DefaultMatrixAutoUpdate (true).
|
||||
*/
|
||||
var matrixAutoUpdate: Boolean
|
||||
/**
|
||||
* When this is set, it calculates the matrixWorld in that frame and resets this property to false. Default is false.
|
||||
*/
|
||||
var matrixWorldNeedsUpdate: Boolean
|
||||
|
||||
var layers: Layers
|
||||
/**
|
||||
* Object gets rendered if true. Default is true.
|
||||
*/
|
||||
var visible: Boolean
|
||||
|
||||
/**
|
||||
* Whether the object gets rendered into shadow map. Default is false.
|
||||
*/
|
||||
var castShadow: Boolean
|
||||
/**
|
||||
* Whether the material receives shadows. Default is false.
|
||||
*/
|
||||
var receiveShadows: Boolean
|
||||
|
||||
/**
|
||||
* When this is set, it checks every frame if the object is in the frustum of the camera before rendering the object.
|
||||
* Otherwise the object gets renderered every frame even if it isn't visible. Default is true.
|
||||
*/
|
||||
var frustrumCulled: Boolean
|
||||
/**
|
||||
* This value allows the default rendering order of scene graph objects to be overridden although opaque and transparent objects remain sorted independently.
|
||||
* Sorting is from lowest to highest renderOrder. Default value is 0.
|
||||
*/
|
||||
var renderOrder: Int
|
||||
|
||||
/**
|
||||
* An object that can be used to store custom data about the Object3D.
|
||||
* It should not hold references to functions as these will not be cloned.
|
||||
*/
|
||||
var userData: Map<String, Any>
|
||||
|
||||
/**
|
||||
* An optional callback that is executed immediately before the Object3D is rendered.
|
||||
* This function is called with the following parameters: renderer, scene, camera, geometry, material, group.
|
||||
*/
|
||||
var onBeforeRender: () -> Unit
|
||||
var onAfterRender: () -> Unit
|
||||
|
||||
/**
|
||||
* Applies the matrix transform to the object and updates the object's position, rotation and scale.
|
||||
*/
|
||||
fun applyMatrix(matrix: Matrix4)
|
||||
|
||||
/**
|
||||
* Applies the rotation represented by the quaternion to the object.
|
||||
*/
|
||||
fun applyQuaternion(q: Quaternion)
|
||||
|
||||
fun setRotationFromAxisAngle(axis: Vector3, angle: Number)
|
||||
fun setRotationFromEuler(euler: Euler)
|
||||
fun setRotationFromMatrix(m: Matrix3)
|
||||
fun setRotationFromQuaternion(q: Quaternion)
|
||||
fun rotateOnAxis(axis: Vector3, angle: Number)
|
||||
fun rotateOnWorldAxis(axis: Vector3, angle: Double)
|
||||
fun rotateX(angle: Number)
|
||||
fun rotateY(angle: Number)
|
||||
fun rotateZ(angle: Number)
|
||||
/**
|
||||
* Translate an object by distance along an axis in object space. The axis is assumed to be normalized.
|
||||
* @param axis A normalized vector in object space.
|
||||
* @param distance The distance to translate.
|
||||
*/
|
||||
fun translateOnAxis(axis: Vector3, distance: Number)
|
||||
|
||||
/**
|
||||
* Translates object along x axis by distance units.
|
||||
*/
|
||||
fun translateX(distance: Number)
|
||||
|
||||
/**
|
||||
* Translates object along y axis by distance units.
|
||||
*/
|
||||
fun translateY(distance: Number)
|
||||
|
||||
/**
|
||||
* Translates object along z axis by distance units.
|
||||
*/
|
||||
fun translateZ(distance: Number)
|
||||
|
||||
/**
|
||||
* Converts the vector from local space to world space.
|
||||
* @param vector A vector representing a position in local (object) space.
|
||||
*/
|
||||
fun localToWorld(vector: Vector3): Vector3
|
||||
|
||||
/**
|
||||
*
|
||||
* Updates the vector from world space to local space.
|
||||
* @param vector A world vector.
|
||||
*/
|
||||
fun worldToLocal(vector: Vector3): Vector3
|
||||
|
||||
/**
|
||||
* Rotates the object to face a point in world space.
|
||||
* This method does not support objects with rotated and/or translated parent(s).
|
||||
* @param v A vector representing a position in world space.
|
||||
*/
|
||||
fun lookAt(v: Vector3)
|
||||
|
||||
/**
|
||||
* Rotates the object to face a point in world space.
|
||||
* This method does not support objects with rotated and/or translated parent(s).
|
||||
* @param x the x component of the world space position.
|
||||
* @param y the y component of the world space position.
|
||||
* @param z the z component of the world space position.
|
||||
*/
|
||||
fun lookAt(x: Number, y: Number, z: Number)
|
||||
|
||||
/**
|
||||
* Adds object as child of this object. An arbitrary number of objects may be added.
|
||||
*/
|
||||
fun add(`object`: Object3D)
|
||||
|
||||
/**
|
||||
* Removes object as child of this object. An arbitrary number of objects may be removed.
|
||||
*/
|
||||
fun remove(`object`: Object3D)
|
||||
|
||||
/**
|
||||
* Searches through the object's children and returns the first with a matching id.
|
||||
* Note that ids are assigned in chronological order: 1, 2, 3, ..., incrementing by one for each new object.
|
||||
* @param id Unique number of the object instance
|
||||
*/
|
||||
fun getObjectById(id: Int): Object3D?
|
||||
|
||||
/**
|
||||
* Searches through the object's children and returns the first with a matching name.
|
||||
* Note that for most objects the # .name is an empty string by default. You will have to set
|
||||
* it manually to make use of this method.
|
||||
* @param name String to match to the children's Object3D.name property.
|
||||
*/
|
||||
fun getObjectByName(name: String): Object3D?
|
||||
|
||||
fun getObjectByProperty(name: String, value: dynamic): Object3D?
|
||||
/**
|
||||
* Returns a vector representing the position of the object in world space.
|
||||
*/
|
||||
fun getWorldPosition(optionalTarget: Vector3 = definedExternally): Vector3
|
||||
|
||||
/**
|
||||
* Returns a quaternion representing the rotation of the object in world space.
|
||||
*/
|
||||
fun getWorldQuaternion(optionalTarget: Quaternion = definedExternally): Quaternion
|
||||
|
||||
/**
|
||||
* Returns the euler angles representing the rotation of the object in world space.
|
||||
*/
|
||||
fun getWorldRotation(optionalTarget: Euler = definedExternally): Euler
|
||||
|
||||
/**
|
||||
*
|
||||
Returns a vector of the scaling factors applied to the object for each axis in world space.
|
||||
*/
|
||||
fun getWorldScale(optionalTarget: Vector3 = definedExternally): Vector3
|
||||
|
||||
/**
|
||||
* Returns a vector representing the direction of object's positive z-axis in world space
|
||||
*/
|
||||
open fun getWorldDirection(optionalTarget: Vector3 = definedExternally): Vector3
|
||||
|
||||
/**
|
||||
* Abstract (empty) method to get intersections between a casted ray and this object.
|
||||
* Subclasses such as Mesh, Line, and Points implement this method in order to use raycasting.
|
||||
*/
|
||||
open fun raycast()
|
||||
|
||||
/**
|
||||
* Executes the callback on this object and all descendants.
|
||||
*/
|
||||
fun traverse(callback: (Object3D) -> Unit)
|
||||
|
||||
/**
|
||||
* Like traverse, but the callback will only be executed for visible objects.
|
||||
* Descendants of invisible objects are not traversed.
|
||||
*/
|
||||
fun traverseVisible(callback: (Object3D) -> Unit)
|
||||
|
||||
/**
|
||||
* Executes the callback on all ancestors.
|
||||
*/
|
||||
fun traverseAncestors(callback: (Object3D) -> Unit)
|
||||
|
||||
/**
|
||||
* Update the local transform
|
||||
*/
|
||||
fun updateMatrix()
|
||||
|
||||
/**
|
||||
* Update the global transform of the object and its children.
|
||||
*/
|
||||
open fun updateMatrixWorld(force: Boolean = definedExternally)
|
||||
|
||||
/**
|
||||
* Convert the object to JSON format.
|
||||
*/
|
||||
fun toJSON(meta: String = definedExternally): Any
|
||||
|
||||
open fun clone(recursive: Boolean = definedExternally): Object3D
|
||||
open fun copy(source: Object3D, recursive: Boolean = definedExternally): Object3D
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,69 @@
|
||||
/*
|
||||
* The MIT License
|
||||
*
|
||||
* Copyright 2017-2018 Lars Ivar Hatledal
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
@file:JsModule("three")
|
||||
@file:JsNonModule
|
||||
|
||||
package info.laht.threekt.core
|
||||
|
||||
import info.laht.threekt.cameras.Camera
|
||||
import info.laht.threekt.math.Ray
|
||||
import info.laht.threekt.math.Vector2
|
||||
import info.laht.threekt.math.Vector3
|
||||
|
||||
external interface Params {
|
||||
var Mesh: dynamic
|
||||
var Line: dynamic
|
||||
var LOD: dynamic
|
||||
var Points: dynamic
|
||||
var Sprite: dynamic
|
||||
}
|
||||
|
||||
external interface Intersect {
|
||||
var distance: Double
|
||||
var distanceToRay: Double?
|
||||
var point: Vector3
|
||||
var index: Int
|
||||
var face: Face3?
|
||||
var faceIndex: Int?
|
||||
var `object`: Object3D
|
||||
}
|
||||
|
||||
external class Raycaster {
|
||||
|
||||
constructor(origin: Vector3, direction: Vector3, near: Number, far: Number)
|
||||
|
||||
var ray: Ray
|
||||
var near: Double
|
||||
var far: Double
|
||||
|
||||
fun set(origin: Vector3, direction: Vector3): Raycaster
|
||||
|
||||
fun setFromCamera(coord: Vector2, camera: Camera)
|
||||
|
||||
fun intersectObject(object3D: Object3D, recursive: Boolean): List<Intersect>
|
||||
|
||||
fun intersectObjects(objects: List<Object3D>, recursive: Boolean): List<Intersect>
|
||||
|
||||
}
|
@ -0,0 +1,39 @@
|
||||
/*
|
||||
* The MIT License
|
||||
*
|
||||
* Copyright 2017-2018 Lars Ivar Hatledal
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
@file:JsModule("three")
|
||||
@file:JsNonModule
|
||||
|
||||
package info.laht.threekt.core
|
||||
|
||||
external class Uniform {
|
||||
|
||||
constructor(value: dynamic)
|
||||
|
||||
var value: dynamic
|
||||
|
||||
fun clone(): Uniform
|
||||
|
||||
}
|
||||
|
42
dataforge-vis-spatial/src/jsMain/kotlin/info/laht/threekt/external/Detector.kt
vendored
Normal file
42
dataforge-vis-spatial/src/jsMain/kotlin/info/laht/threekt/external/Detector.kt
vendored
Normal file
@ -0,0 +1,42 @@
|
||||
/*
|
||||
* The MIT License
|
||||
*
|
||||
* Copyright 2017-2018 Lars Ivar Hatledal
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
@file:JsModule("three")
|
||||
@file:JsNonModule
|
||||
|
||||
package info.laht.threekt.external
|
||||
|
||||
import org.w3c.dom.Element
|
||||
|
||||
external object Detector {
|
||||
|
||||
val webgl: Boolean
|
||||
val canvas: Boolean
|
||||
val workers: Boolean
|
||||
val fileapi: Boolean
|
||||
|
||||
fun getWebGLErrorMessage(): Element
|
||||
fun addGetWebGLMessage(parameters: dynamic)
|
||||
|
||||
}
|
34
dataforge-vis-spatial/src/jsMain/kotlin/info/laht/threekt/external/ImprovedNoise.kt
vendored
Normal file
34
dataforge-vis-spatial/src/jsMain/kotlin/info/laht/threekt/external/ImprovedNoise.kt
vendored
Normal file
@ -0,0 +1,34 @@
|
||||
/*
|
||||
* The MIT License
|
||||
*
|
||||
* Copyright 2017-2018 Lars Ivar Hatledal
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
@file:JsModule("three")
|
||||
@file:JsNonModule
|
||||
|
||||
package info.laht.threekt.external
|
||||
|
||||
external object ImprovedNoise {
|
||||
|
||||
fun noise(x: Double, y: Double, z: Double): Double
|
||||
|
||||
}
|
33
dataforge-vis-spatial/src/jsMain/kotlin/info/laht/threekt/external/SimplexNoise.kt
vendored
Normal file
33
dataforge-vis-spatial/src/jsMain/kotlin/info/laht/threekt/external/SimplexNoise.kt
vendored
Normal file
@ -0,0 +1,33 @@
|
||||
/*
|
||||
* The MIT License
|
||||
*
|
||||
* Copyright 2017-2018 Lars Ivar Hatledal
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
@file:JsModule("three")
|
||||
@file:JsNonModule
|
||||
|
||||
package info.laht.threekt.external
|
||||
|
||||
external object SimplexNoise {
|
||||
|
||||
|
||||
}
|
51
dataforge-vis-spatial/src/jsMain/kotlin/info/laht/threekt/external/controls/FlyControls.kt
vendored
Normal file
51
dataforge-vis-spatial/src/jsMain/kotlin/info/laht/threekt/external/controls/FlyControls.kt
vendored
Normal file
@ -0,0 +1,51 @@
|
||||
/*
|
||||
* The MIT License
|
||||
*
|
||||
* Copyright 2017-2018 Lars Ivar Hatledal
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
@file:JsModule("three/examples/jsm/controls/FlyControls.js")
|
||||
@file:JsNonModule
|
||||
|
||||
package info.laht.threekt.external.controls
|
||||
|
||||
import info.laht.threekt.core.Object3D
|
||||
import org.w3c.dom.Node
|
||||
|
||||
external class FlyControls(`object`: Object3D, domElement: Node = definedExternally) {
|
||||
|
||||
var `object`: Object3D
|
||||
var domElement: Node
|
||||
|
||||
// API
|
||||
|
||||
var movementSpeed: Double
|
||||
var rollSpeed: Double
|
||||
|
||||
var dragToLook: Boolean
|
||||
var autoForward: Boolean
|
||||
|
||||
|
||||
fun update(delta: Number)
|
||||
|
||||
fun dispose()
|
||||
|
||||
}
|
110
dataforge-vis-spatial/src/jsMain/kotlin/info/laht/threekt/external/controls/OrbitControls.kt
vendored
Normal file
110
dataforge-vis-spatial/src/jsMain/kotlin/info/laht/threekt/external/controls/OrbitControls.kt
vendored
Normal file
@ -0,0 +1,110 @@
|
||||
/*
|
||||
* The MIT License
|
||||
*
|
||||
* Copyright 2017-2018 Lars Ivar Hatledal
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
@file:JsModule("three/examples/jsm/controls/OrbitControls.js")
|
||||
@file:JsNonModule
|
||||
|
||||
package info.laht.threekt.external.controls
|
||||
|
||||
import info.laht.threekt.core.Object3D
|
||||
import info.laht.threekt.math.Vector3
|
||||
import org.w3c.dom.Node
|
||||
|
||||
/**
|
||||
* This set of controls performs orbiting, dollying (zooming), and panning.
|
||||
* Unlike TrackballControls, it maintains the "up" direction object.up (+Y by default).
|
||||
*
|
||||
* Orbit - left mouse / touch: one finger move
|
||||
* Zoom - middle mouse, or mousewheel / touch: two finger spread or squish
|
||||
* Pan - right mouse, or arrow keys / touch: three finger swipe
|
||||
*/
|
||||
|
||||
external class OrbitControls(`object`: Object3D, domElement: Node = definedExternally) {
|
||||
|
||||
var `object`: Object3D
|
||||
|
||||
var domElement: Node
|
||||
|
||||
var enabled: Boolean
|
||||
|
||||
var target: Vector3
|
||||
|
||||
var minDistance: Double
|
||||
var maxDistance: Double
|
||||
|
||||
var minZoom: Double
|
||||
var maxZoom: Double
|
||||
|
||||
/**
|
||||
* How far you can orbit vertically, lower limit.
|
||||
* In radians
|
||||
*/
|
||||
var minPolarAngle: Double
|
||||
/**
|
||||
* How far you can orbit vertically, upper limit.
|
||||
* In radians
|
||||
*/
|
||||
var maxPolarAngle: Double
|
||||
|
||||
var minAzimuthAngle: Double
|
||||
var maxAzimuthAngle: Double
|
||||
|
||||
var enableDamping: Boolean
|
||||
var dampingFactor: Double
|
||||
|
||||
var enableZoom: Boolean
|
||||
var zoomSpeed: Double
|
||||
|
||||
var enableRotate: Boolean
|
||||
var rotateSpeed: Double
|
||||
|
||||
var enablePan: Boolean
|
||||
var keyPanSpeed: Double
|
||||
|
||||
var autoRotate: Boolean
|
||||
var autoRotateSpeed: Double
|
||||
|
||||
var enableKeys: Boolean
|
||||
|
||||
interface Keys {
|
||||
var LEFT: Int
|
||||
var UP: Int
|
||||
var RIGHT: Int
|
||||
var BOTTOM: Int
|
||||
}
|
||||
|
||||
var keys: Keys
|
||||
|
||||
fun getPolarAngle(): Double
|
||||
|
||||
fun getAzimutAngle(): Double
|
||||
|
||||
fun saveState()
|
||||
|
||||
fun reset()
|
||||
|
||||
fun update()
|
||||
|
||||
fun dispose()
|
||||
}
|
60
dataforge-vis-spatial/src/jsMain/kotlin/info/laht/threekt/external/controls/TrackballControls.kt
vendored
Normal file
60
dataforge-vis-spatial/src/jsMain/kotlin/info/laht/threekt/external/controls/TrackballControls.kt
vendored
Normal file
@ -0,0 +1,60 @@
|
||||
@file:Suppress(
|
||||
"INTERFACE_WITH_SUPERCLASS",
|
||||
"OVERRIDING_FINAL_MEMBER",
|
||||
"RETURN_TYPE_MISMATCH_ON_OVERRIDE",
|
||||
"CONFLICTING_OVERLOADS",
|
||||
"EXTERNAL_DELEGATION",
|
||||
"NESTED_CLASS_IN_EXTERNAL_INTERFACE"
|
||||
)
|
||||
@file:JsModule("three/examples/jsm/controls/TrackballControls.js")
|
||||
@file:JsNonModule
|
||||
|
||||
package info.laht.threekt.external.controls
|
||||
|
||||
import info.laht.threekt.cameras.Camera
|
||||
import info.laht.threekt.core.EventDispatcher
|
||||
import info.laht.threekt.math.Vector3
|
||||
import org.w3c.dom.HTMLElement
|
||||
import org.w3c.dom.Node
|
||||
|
||||
external interface `T$0` {
|
||||
var left: Number
|
||||
var top: Number
|
||||
var width: Number
|
||||
var height: Number
|
||||
}
|
||||
|
||||
external open class TrackballControls(
|
||||
`object`: Camera,
|
||||
domElement: Node = definedExternally /* null */
|
||||
) : EventDispatcher {
|
||||
open var `object`: Camera
|
||||
open var domElement: HTMLElement
|
||||
open var enabled: Boolean
|
||||
open var screen: `T$0`
|
||||
open var rotateSpeed: Number
|
||||
open var zoomSpeed: Number
|
||||
open var panSpeed: Number
|
||||
open var noRotate: Boolean
|
||||
open var noZoom: Boolean
|
||||
open var noPan: Boolean
|
||||
open var noRoll: Boolean
|
||||
open var staticMoving: Boolean
|
||||
open var dynamicDampingFactor: Number
|
||||
open var minDistance: Number
|
||||
open var maxDistance: Number
|
||||
open var keys: Array<Number>
|
||||
open var target: Vector3
|
||||
open var position0: Vector3
|
||||
open var target0: Vector3
|
||||
open var up0: Vector3
|
||||
open fun update(): Unit
|
||||
open fun reset(): Unit
|
||||
open fun dispose(): Unit
|
||||
open fun checkDistances(): Unit
|
||||
open fun zoomCamera(): Unit
|
||||
open fun panCamera(): Unit
|
||||
open fun rotateCamera(): Unit
|
||||
open fun handleResize(): Unit
|
||||
open fun handleEvent(event: Any): Unit
|
||||
}
|
47
dataforge-vis-spatial/src/jsMain/kotlin/info/laht/threekt/external/controls/TransformControls.kt
vendored
Normal file
47
dataforge-vis-spatial/src/jsMain/kotlin/info/laht/threekt/external/controls/TransformControls.kt
vendored
Normal file
@ -0,0 +1,47 @@
|
||||
/*
|
||||
* The MIT License
|
||||
*
|
||||
* Copyright 2017-2018 Lars Ivar Hatledal
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
@file:JsModule("three/examples/jsm/controls/TransformControls.js")
|
||||
@file:JsNonModule
|
||||
|
||||
package info.laht.threekt.external.controls
|
||||
|
||||
import info.laht.threekt.core.Object3D
|
||||
import org.w3c.dom.Node
|
||||
|
||||
external class TransformControls(`object`: Object3D, domElement: Node = definedExternally) : Object3D {
|
||||
|
||||
var `object`: Object3D
|
||||
var domElement: Node
|
||||
|
||||
fun setSpace(space: String)
|
||||
fun setTranslationSnap(snap: Number)
|
||||
fun setRotationSnap(snap: Number)
|
||||
fun setMode(mode: String)
|
||||
fun setSize(size: Number)
|
||||
|
||||
fun update()
|
||||
fun addEventListener(event: String, listener: () -> Unit)
|
||||
|
||||
}
|
36
dataforge-vis-spatial/src/jsMain/kotlin/info/laht/threekt/external/exporters/OBJExporter.kt
vendored
Normal file
36
dataforge-vis-spatial/src/jsMain/kotlin/info/laht/threekt/external/exporters/OBJExporter.kt
vendored
Normal file
@ -0,0 +1,36 @@
|
||||
/*
|
||||
* The MIT License
|
||||
*
|
||||
* Copyright 2017-2018 Lars Ivar Hatledal
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
@file:JsModule("three/examples/jsm/exporters/OBJExporter.js")
|
||||
@file:JsNonModule
|
||||
|
||||
package info.laht.threekt.external.exporters
|
||||
|
||||
import info.laht.threekt.core.Object3D
|
||||
|
||||
external class OBJExporter {
|
||||
|
||||
fun parse(`object`: Object3D): String
|
||||
|
||||
}
|
43
dataforge-vis-spatial/src/jsMain/kotlin/info/laht/threekt/external/exporters/STLExporter.kt
vendored
Normal file
43
dataforge-vis-spatial/src/jsMain/kotlin/info/laht/threekt/external/exporters/STLExporter.kt
vendored
Normal file
@ -0,0 +1,43 @@
|
||||
/*
|
||||
* The MIT License
|
||||
*
|
||||
* Copyright 2017-2018 Lars Ivar Hatledal
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
@file:JsModule("three/examples/jsm/exporters/STLExporter.js")
|
||||
@file:JsNonModule
|
||||
|
||||
package info.laht.threekt.external.exporters
|
||||
|
||||
import info.laht.threekt.core.Object3D
|
||||
import org.khronos.webgl.DataView
|
||||
|
||||
external class STLExporter {
|
||||
|
||||
fun parse(scene: Object3D): String
|
||||
|
||||
}
|
||||
|
||||
external class STLBinaryExporter {
|
||||
|
||||
fun parse(scene: Object3D): DataView
|
||||
|
||||
}
|
11
dataforge-vis-spatial/src/jsMain/kotlin/info/laht/threekt/external/geometries/ConvexGeometry.kt
vendored
Normal file
11
dataforge-vis-spatial/src/jsMain/kotlin/info/laht/threekt/external/geometries/ConvexGeometry.kt
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
@file:JsModule("three/examples/jsm/geometries/ConvexGeometry.js")
|
||||
@file:JsNonModule
|
||||
|
||||
package info.laht.threekt.external.geometries
|
||||
|
||||
import info.laht.threekt.core.BufferGeometry
|
||||
import info.laht.threekt.math.Vector3
|
||||
|
||||
external class ConvexGeometry(points: Array<Vector3>) : BufferGeometry
|
||||
|
||||
external class ConvexBufferGeometry(points: Array<Vector3>) : BufferGeometry
|
21
dataforge-vis-spatial/src/jsMain/kotlin/info/laht/threekt/external/libs/GUIParams.kt
vendored
Normal file
21
dataforge-vis-spatial/src/jsMain/kotlin/info/laht/threekt/external/libs/GUIParams.kt
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
package info.laht.threekt.external.libs
|
||||
|
||||
/**
|
||||
* @param name The name of this GUI
|
||||
* @param load JSON object representing the saved state of this GUI
|
||||
* @param auto default true
|
||||
* @param parent The GUI I'm nested in
|
||||
* @param closed If true, starts closed
|
||||
* @param closeOnTop If true, close/open button shows on top of the GUI
|
||||
* @param width
|
||||
*/
|
||||
data class GUIParams(
|
||||
var name: String? = undefined,
|
||||
var auto: Boolean? = undefined,
|
||||
var load: dynamic = undefined,
|
||||
var parent: dat.GUI? = undefined,
|
||||
var closed: Boolean? = undefined,
|
||||
var closeOnTop: Boolean? = undefined,
|
||||
var autoPlace: Boolean? = undefined,
|
||||
var width: Int? = undefined
|
||||
)
|
41
dataforge-vis-spatial/src/jsMain/kotlin/info/laht/threekt/external/libs/Stats.kt
vendored
Normal file
41
dataforge-vis-spatial/src/jsMain/kotlin/info/laht/threekt/external/libs/Stats.kt
vendored
Normal file
@ -0,0 +1,41 @@
|
||||
/*
|
||||
* The MIT License
|
||||
*
|
||||
* Copyright 2017-2018 Lars Ivar Hatledal
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
@file:JsModule("three/examples/jsm/libs/stats.module.js")
|
||||
@file:JsNonModule
|
||||
|
||||
package info.laht.threekt.external.libs
|
||||
|
||||
import org.w3c.dom.Node
|
||||
|
||||
/**
|
||||
* https://github.com/mrdoob/stats.js/
|
||||
*/
|
||||
external class Stats {
|
||||
|
||||
val dom: Node
|
||||
|
||||
fun update()
|
||||
|
||||
}
|
154
dataforge-vis-spatial/src/jsMain/kotlin/info/laht/threekt/external/libs/datgui.kt
vendored
Normal file
154
dataforge-vis-spatial/src/jsMain/kotlin/info/laht/threekt/external/libs/datgui.kt
vendored
Normal file
@ -0,0 +1,154 @@
|
||||
/*
|
||||
* The MIT License
|
||||
*
|
||||
* Copyright 2017-2018 Lars Ivar Hatledal
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
@file:JsModule("three/examples/jsm/libs/dat.gui.module.js")
|
||||
@file:JsNonModule
|
||||
|
||||
package info.laht.threekt.external.libs
|
||||
|
||||
import org.w3c.dom.Element
|
||||
|
||||
/**
|
||||
* https://github.com/dataarts/dat.gui/blob/master/src/dat/gui/val js
|
||||
*/
|
||||
external class dat {
|
||||
|
||||
class GUI(
|
||||
params: GUIParams = definedExternally
|
||||
) {
|
||||
|
||||
companion object {
|
||||
|
||||
val CLASS_AUTO_PLACE: String
|
||||
val CLASS_AUTO_PLACE_CONTAINER: String
|
||||
val CLASS_MAIN: String
|
||||
val CLASS_CONTROLLER_ROW: String
|
||||
val CLASS_TOO_TALL: String
|
||||
val CLASS_CLOSED: String
|
||||
val CLASS_CLOSE_BUTTON: String
|
||||
val CLASS_CLOSE_TOP: String
|
||||
val CLASS_CLOSE_BOTTOM: String
|
||||
val CLASS_DRAG: String
|
||||
|
||||
val DEFAULT_WIDTH: Int
|
||||
val TEXT_CLOSED: String
|
||||
val TEXT_OPEN: String
|
||||
|
||||
fun toggleHide()
|
||||
}
|
||||
|
||||
val domElement: Element
|
||||
val parent: GUI
|
||||
val scrollable: Boolean
|
||||
val autoPlace: Boolean
|
||||
val closeOnTop: Boolean
|
||||
var preset: String
|
||||
var width: Number
|
||||
var name: String
|
||||
var closed: Boolean
|
||||
val load: dynamic
|
||||
var useLocalStorage: Boolean
|
||||
|
||||
fun add(`object`: dynamic, property: String, vararg args: dynamic): Controller
|
||||
|
||||
fun addColor(`object`: dynamic, property: String): ColorController
|
||||
|
||||
fun destroy()
|
||||
|
||||
fun addFolder(name: String): GUI
|
||||
|
||||
fun open()
|
||||
|
||||
fun close()
|
||||
|
||||
fun onResize()
|
||||
|
||||
fun remember(`object`: dynamic)
|
||||
|
||||
fun getRoot(): GUI
|
||||
|
||||
fun getSaveObject(): dynamic
|
||||
|
||||
fun save()
|
||||
|
||||
fun saveAs(presetName: String)
|
||||
|
||||
fun revert(gui: GUI = definedExternally)
|
||||
|
||||
fun listen(controller: Controller)
|
||||
|
||||
fun updateDisplay(controller: Controller)
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
external interface Controller {
|
||||
|
||||
val initialValue: dynamic
|
||||
val domElement: Element
|
||||
|
||||
val `object`: dynamic
|
||||
val property: String
|
||||
|
||||
fun onChange(fnc: () -> Unit)
|
||||
fun onFinishChange(fnc: () -> Unit)
|
||||
fun setValue(newValue: dynamic): Controller
|
||||
fun getValue(): dynamic
|
||||
fun updateDisplay(): Controller
|
||||
fun isModified(): Boolean
|
||||
|
||||
}
|
||||
|
||||
external interface StringController : Controller
|
||||
|
||||
external interface BooleanController : Controller {
|
||||
|
||||
val __checkbox: Element
|
||||
val __prev: dynamic
|
||||
|
||||
}
|
||||
|
||||
external interface NumberController : Controller {
|
||||
|
||||
val __min: Number
|
||||
val __max: Number
|
||||
val __step: Number
|
||||
val __impliedStep: Number?
|
||||
val __precision: Number?
|
||||
|
||||
fun min(minValue: Number): NumberController
|
||||
fun max(maxValue: Number): NumberController
|
||||
fun step(step: Number): NumberController
|
||||
|
||||
}
|
||||
|
||||
external interface NumberControllerSlider : NumberController
|
||||
external interface NumberControllerBox : NumberController
|
||||
|
||||
external interface ColorController : Controller
|
||||
|
||||
external interface OptionController : Controller {
|
||||
val __select: Element
|
||||
}
|
||||
|
55
dataforge-vis-spatial/src/jsMain/kotlin/info/laht/threekt/external/loaders/BabylonLoader.kt
vendored
Normal file
55
dataforge-vis-spatial/src/jsMain/kotlin/info/laht/threekt/external/loaders/BabylonLoader.kt
vendored
Normal file
@ -0,0 +1,55 @@
|
||||
/*
|
||||
* The MIT License
|
||||
*
|
||||
* Copyright 2017-2018 Lars Ivar Hatledal
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
@file:JsModule("three")
|
||||
@file:JsNonModule
|
||||
|
||||
package info.laht.threekt.external.loaders
|
||||
|
||||
import info.laht.threekt.core.Object3D
|
||||
import info.laht.threekt.loaders.LoadingManager
|
||||
import org.w3c.xhr.XMLHttpRequest
|
||||
|
||||
external class BabylonLoader(
|
||||
manager: LoadingManager = definedExternally
|
||||
) {
|
||||
|
||||
/**
|
||||
* Begin loading from url and call onLoad with the parsed response content.
|
||||
*/
|
||||
fun load(
|
||||
url: String,
|
||||
onLoad: (Object3D) -> Unit,
|
||||
onProgress: (XMLHttpRequest) -> Unit = definedExternally,
|
||||
onError: (dynamic) -> Unit = definedExternally
|
||||
)
|
||||
|
||||
/**
|
||||
* Parse a JSON structure and return an object or a scene.
|
||||
* Found objects are converted to Mesh with a BufferGeometry and a default MeshPhongMaterial.
|
||||
* Lights are parsed accordingly.
|
||||
*/
|
||||
fun parse(json: String): Object3D
|
||||
|
||||
}
|
61
dataforge-vis-spatial/src/jsMain/kotlin/info/laht/threekt/external/loaders/GLTFLoader.kt
vendored
Normal file
61
dataforge-vis-spatial/src/jsMain/kotlin/info/laht/threekt/external/loaders/GLTFLoader.kt
vendored
Normal file
@ -0,0 +1,61 @@
|
||||
@file:JsModule("three")
|
||||
@file:JsNonModule
|
||||
|
||||
package info.laht.threekt.external.loaders
|
||||
|
||||
import info.laht.threekt.animation.AnimationClip
|
||||
import info.laht.threekt.cameras.Camera
|
||||
import info.laht.threekt.loaders.LoadingManager
|
||||
import info.laht.threekt.scenes.Scene
|
||||
import org.khronos.webgl.ArrayBuffer
|
||||
import org.w3c.xhr.XMLHttpRequest
|
||||
|
||||
external interface GLTFOnLoadCallback {
|
||||
val animations: Array<AnimationClip>
|
||||
val scene: Scene
|
||||
val scenes: Array<Scene>
|
||||
val cameras: Array<Camera>
|
||||
}
|
||||
|
||||
/**
|
||||
* A loader for loading glTF 2.0 resource.
|
||||
* glTF (GL Transmission Format) is an open format specification for efficient delivery
|
||||
* and loading of 3D content. Assets may be provided either in JSON (.gltf) or binary (.glb) format.
|
||||
* External files store textures (.jpg, .png, ...) and additional binary data (.bin).
|
||||
* A glTF asset may deliver one or more scenes, including meshes, materials, textures, skins,
|
||||
* skeletons, morph targets, animations, lights, and/or cameras.
|
||||
*/
|
||||
external class GLTFLoader(
|
||||
manager: LoadingManager = definedExternally
|
||||
) {
|
||||
|
||||
/**
|
||||
* Begin loading from url and call the callback function with the parsed response content.
|
||||
*/
|
||||
fun load(
|
||||
url: String,
|
||||
onLoad: (GLTFOnLoadCallback) -> Unit,
|
||||
onProgress: (XMLHttpRequest) -> Unit = definedExternally,
|
||||
onError: (dynamic) -> Unit = definedExternally
|
||||
)
|
||||
|
||||
/**
|
||||
* Set the base path for additional resources.
|
||||
*/
|
||||
fun setPath(path: String)
|
||||
|
||||
fun setCrossOrigin(value: String)
|
||||
|
||||
/**
|
||||
* Parse a glTF-based ArrayBuffer and fire onLoad callback when complete.
|
||||
* The argument to onLoad will be an object that contains loaded parts: .scene, .scenes, .cameras, and .animations.
|
||||
*/
|
||||
fun parse(data: ArrayBuffer, path: String, onLoad: (GLTFOnLoadCallback) -> Unit, onError: (dynamic) -> Unit)
|
||||
|
||||
/**
|
||||
* Parse a glTF-based JSON String and fire onLoad callback when complete.
|
||||
* The argument to onLoad will be an object that contains loaded parts: .scene, .scenes, .cameras, and .animations.
|
||||
*/
|
||||
fun parse(data: String, path: String, onLoad: (GLTFOnLoadCallback) -> Unit, onError: (dynamic) -> Unit)
|
||||
|
||||
}
|
41
dataforge-vis-spatial/src/jsMain/kotlin/info/laht/threekt/external/loaders/LoaderSupport.kt
vendored
Normal file
41
dataforge-vis-spatial/src/jsMain/kotlin/info/laht/threekt/external/loaders/LoaderSupport.kt
vendored
Normal file
@ -0,0 +1,41 @@
|
||||
/*
|
||||
* The MIT License
|
||||
*
|
||||
* Copyright 2017-2018 Lars Ivar Hatledal
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
@file:JsModule("three")
|
||||
@file:JsNonModule
|
||||
|
||||
package info.laht.threekt.external.loaders
|
||||
|
||||
external object LoaderSupport {
|
||||
|
||||
object LoaderBase
|
||||
object Validator
|
||||
object ConsoleLogger
|
||||
object Callbacks
|
||||
object LoadedMeshUserOverride
|
||||
object ResourceDescriptor
|
||||
object PrepData
|
||||
|
||||
}
|
||||
|
53
dataforge-vis-spatial/src/jsMain/kotlin/info/laht/threekt/external/loaders/MTLLoader.kt
vendored
Normal file
53
dataforge-vis-spatial/src/jsMain/kotlin/info/laht/threekt/external/loaders/MTLLoader.kt
vendored
Normal file
@ -0,0 +1,53 @@
|
||||
/*
|
||||
* The MIT License
|
||||
*
|
||||
* Copyright 2017-2018 Lars Ivar Hatledal
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
@file:JsModule("three")
|
||||
@file:JsNonModule
|
||||
|
||||
package info.laht.threekt.external.loaders
|
||||
|
||||
import info.laht.threekt.core.Object3D
|
||||
import info.laht.threekt.loaders.LoadingManager
|
||||
import org.w3c.xhr.XMLHttpRequest
|
||||
|
||||
external class MTLLoader(
|
||||
loadingManager: LoadingManager = definedExternally
|
||||
) {
|
||||
|
||||
fun load(
|
||||
url: String,
|
||||
onLoad: (Object3D) -> Unit,
|
||||
onProgress: (XMLHttpRequest) -> Unit = definedExternally,
|
||||
onError: () -> Unit = definedExternally
|
||||
)
|
||||
|
||||
fun setTexturePath(path: String)
|
||||
fun setBaseUrl(path: String)
|
||||
fun setCrossOrigin(value: String)
|
||||
|
||||
fun parse(text: String): MaterialCreator
|
||||
|
||||
}
|
||||
|
||||
external class MaterialCreator(baseUrl: String = definedExternally)
|
57
dataforge-vis-spatial/src/jsMain/kotlin/info/laht/threekt/external/loaders/OBJLoader.kt
vendored
Normal file
57
dataforge-vis-spatial/src/jsMain/kotlin/info/laht/threekt/external/loaders/OBJLoader.kt
vendored
Normal file
@ -0,0 +1,57 @@
|
||||
/*
|
||||
* The MIT License
|
||||
*
|
||||
* Copyright 2017-2018 Lars Ivar Hatledal
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
@file:JsModule("three")
|
||||
@file:JsNonModule
|
||||
|
||||
package info.laht.threekt.external.loaders
|
||||
|
||||
import info.laht.threekt.core.Object3D
|
||||
import info.laht.threekt.loaders.LoadingManager
|
||||
import info.laht.threekt.objects.Mesh
|
||||
import org.w3c.xhr.XMLHttpRequest
|
||||
|
||||
/**
|
||||
* A loader for loading a .obj resource.
|
||||
* The OBJ file format is a simple data-format that represents 3D geometry in a human redeable format as,
|
||||
* the position of each vertex,the UV position of each texture coordinate vertex, vertex normals,
|
||||
* and the faces that make each polygon defined as a list of vertices, and texture vertices.
|
||||
*/
|
||||
external class OBJLoader(
|
||||
manager: LoadingManager = definedExternally
|
||||
) {
|
||||
|
||||
fun load(
|
||||
url: String,
|
||||
onLoad: (Mesh) -> Unit,
|
||||
onProgress: (XMLHttpRequest) -> Unit = definedExternally,
|
||||
onError: (dynamic) -> Unit = definedExternally
|
||||
)
|
||||
|
||||
fun setPath(value: String)
|
||||
|
||||
fun parse(text: String): Object3D
|
||||
|
||||
}
|
||||
|
74
dataforge-vis-spatial/src/jsMain/kotlin/info/laht/threekt/external/loaders/OBJLoader2.kt
vendored
Normal file
74
dataforge-vis-spatial/src/jsMain/kotlin/info/laht/threekt/external/loaders/OBJLoader2.kt
vendored
Normal file
@ -0,0 +1,74 @@
|
||||
/*
|
||||
* The MIT License
|
||||
*
|
||||
* Copyright 2017-2018 Lars Ivar Hatledal
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
@file:JsModule("three")
|
||||
@file:JsNonModule
|
||||
|
||||
package info.laht.threekt.external.loaders
|
||||
|
||||
import info.laht.threekt.loaders.LoadingManager
|
||||
import info.laht.threekt.objects.Mesh
|
||||
import org.w3c.xhr.XMLHttpRequest
|
||||
|
||||
external interface Detail {
|
||||
var loaderRootNode: Mesh
|
||||
var modelName: String
|
||||
var instanceNo: Int
|
||||
}
|
||||
|
||||
external interface OBJ2OnLoadCallback {
|
||||
var detail: Detail
|
||||
}
|
||||
|
||||
external interface LoaderProxy {
|
||||
fun load(
|
||||
url: String,
|
||||
onLoad: (OBJ2OnLoadCallback) -> Unit,
|
||||
onProgress: (XMLHttpRequest) -> Unit = definedExternally,
|
||||
onError: (dynamic) -> Unit = definedExternally,
|
||||
onMeshAlter: () -> Unit = definedExternally,
|
||||
useAsync: Boolean = definedExternally
|
||||
)
|
||||
}
|
||||
|
||||
external class OBJLoader2(
|
||||
manager: LoadingManager = definedExternally,
|
||||
logger: LoaderSupport.ConsoleLogger = definedExternally
|
||||
) : LoaderProxy {
|
||||
|
||||
companion object {
|
||||
val OBJLOADER2_VERSION: String
|
||||
val LoaderBase: LoaderSupport.LoaderBase
|
||||
val Validator: LoaderSupport.Validator
|
||||
}
|
||||
|
||||
override fun load(
|
||||
url: String,
|
||||
onLoad: (OBJ2OnLoadCallback) -> Unit,
|
||||
onProgress: (XMLHttpRequest) -> Unit,
|
||||
onError: (dynamic) -> Unit,
|
||||
onMeshAlter: () -> Unit,
|
||||
useAsync: Boolean
|
||||
)
|
||||
}
|
46
dataforge-vis-spatial/src/jsMain/kotlin/info/laht/threekt/external/loaders/STLLoader.kt
vendored
Normal file
46
dataforge-vis-spatial/src/jsMain/kotlin/info/laht/threekt/external/loaders/STLLoader.kt
vendored
Normal file
@ -0,0 +1,46 @@
|
||||
/*
|
||||
* The MIT License
|
||||
*
|
||||
* Copyright 2017-2018 Lars Ivar Hatledal
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
@file:JsModule("three")
|
||||
@file:JsNonModule
|
||||
|
||||
package info.laht.threekt.external.loaders
|
||||
|
||||
import info.laht.threekt.core.BufferGeometry
|
||||
import info.laht.threekt.core.Object3D
|
||||
import org.w3c.xhr.XMLHttpRequest
|
||||
|
||||
external class STLLoader {
|
||||
|
||||
fun load(
|
||||
url: String,
|
||||
onLoad: (BufferGeometry) -> Unit,
|
||||
onProgress: (XMLHttpRequest) -> Unit = definedExternally,
|
||||
onError: () -> Unit = definedExternally
|
||||
)
|
||||
|
||||
fun parse(data: String): Object3D
|
||||
fun parse(data: ByteArray): Object3D
|
||||
|
||||
}
|
32
dataforge-vis-spatial/src/jsMain/kotlin/info/laht/threekt/external/objects/Sky.kt
vendored
Normal file
32
dataforge-vis-spatial/src/jsMain/kotlin/info/laht/threekt/external/objects/Sky.kt
vendored
Normal file
@ -0,0 +1,32 @@
|
||||
/*
|
||||
* The MIT License
|
||||
*
|
||||
* Copyright 2017-2018 Lars Ivar Hatledal
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
@file:JsModule("three")
|
||||
@file:JsNonModule
|
||||
|
||||
package info.laht.threekt.external.objects
|
||||
|
||||
import info.laht.threekt.objects.Mesh
|
||||
|
||||
external class Sky : Mesh
|
32
dataforge-vis-spatial/src/jsMain/kotlin/info/laht/threekt/external/objects/Water.kt
vendored
Normal file
32
dataforge-vis-spatial/src/jsMain/kotlin/info/laht/threekt/external/objects/Water.kt
vendored
Normal file
@ -0,0 +1,32 @@
|
||||
/*
|
||||
* The MIT License
|
||||
*
|
||||
* Copyright 2017-2018 Lars Ivar Hatledal
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
@file:JsModule("three")
|
||||
@file:JsNonModule
|
||||
|
||||
package info.laht.threekt.external.objects
|
||||
|
||||
import info.laht.threekt.objects.Mesh
|
||||
|
||||
external class Water(width: Int, height: Int, options: WaterOptions = definedExternally) : Mesh
|
47
dataforge-vis-spatial/src/jsMain/kotlin/info/laht/threekt/external/objects/WaterOptions.kt
vendored
Normal file
47
dataforge-vis-spatial/src/jsMain/kotlin/info/laht/threekt/external/objects/WaterOptions.kt
vendored
Normal file
@ -0,0 +1,47 @@
|
||||
/*
|
||||
* The MIT License
|
||||
*
|
||||
* Copyright 2017-2018 Lars Ivar Hatledal
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package info.laht.threekt.external.objects
|
||||
|
||||
import info.laht.threekt.math.Vector3
|
||||
import info.laht.threekt.textures.Texture
|
||||
|
||||
data class WaterOptions(
|
||||
|
||||
val textureWidth: Int? = undefined,
|
||||
val textureHeight: Int? = undefined,
|
||||
|
||||
val clipBias: Number? = undefined,
|
||||
val alpha: Number? = undefined,
|
||||
val time: Number? = undefined,
|
||||
val waterNormals: Texture? = undefined,
|
||||
val sunDirection: Vector3? = undefined,
|
||||
val sunColor: Int? = undefined,
|
||||
val waterColor: Int? = undefined,
|
||||
val eye: Vector3? = undefined,
|
||||
val distortionScale: Number? = undefined,
|
||||
val side: Int? = undefined,
|
||||
val fog: Boolean? = undefined
|
||||
|
||||
)
|
@ -0,0 +1,44 @@
|
||||
@file:JsModule("three")
|
||||
@file:JsNonModule
|
||||
|
||||
package info.laht.threekt.extras
|
||||
|
||||
import info.laht.threekt.core.BufferGeometry
|
||||
import info.laht.threekt.core.Object3D
|
||||
import info.laht.threekt.materials.Material
|
||||
import info.laht.threekt.objects.Group
|
||||
import info.laht.threekt.scenes.Scene
|
||||
|
||||
/**
|
||||
* A class containing useful utility functions for scene manipulation.
|
||||
*/
|
||||
external object SceneUtils {
|
||||
|
||||
/**
|
||||
* Creates a new Group that contains a new mesh for each material defined in materials. Beware that this is not the same as an array of materials which defines multiple materials for 1 mesh.
|
||||
* This is mostly useful for objects that need both a material and a wireframe implementation.
|
||||
* @param geometry The geometry for the set of materials.
|
||||
* @param materials The materials for the object.
|
||||
*/
|
||||
fun createMultiMaterialObject(geometry: BufferGeometry, materials: List<Material>): Group
|
||||
|
||||
/**
|
||||
* Detaches the object from the parent and adds it back to the scene without moving in worldspace. B
|
||||
* eware that to do this the matrixWorld needs to be updated, this can be done by calling the updateMatrixWorld method on the parent object.
|
||||
* @param child The object to remove from the parent
|
||||
* @param parent The scene to attach the object on.
|
||||
* @param scene The parent to detach the object from.
|
||||
*/
|
||||
fun detach(child: Object3D, parent: Object3D, scene: Scene)
|
||||
|
||||
/**
|
||||
* Attaches the object to the parent without the moving the object in the worldspace.
|
||||
* Beware that to do this the matrixWorld needs to be updated, this can be done by calling the updateMatrixWorld method on the parent object.
|
||||
*
|
||||
* @param child The object to remove from the parent
|
||||
* @param parent The scene to attach the object on.
|
||||
* @param scene The parent to detach the object from.
|
||||
*/
|
||||
fun attach(child: Object3D, parent: Object3D, scene: Scene)
|
||||
|
||||
}
|
@ -0,0 +1,35 @@
|
||||
@file:JsModule("three")
|
||||
@file:JsNonModule
|
||||
|
||||
package info.laht.threekt.extras.core
|
||||
|
||||
|
||||
external abstract class Curve<E> {
|
||||
|
||||
var arcLengthDivisions: Int
|
||||
|
||||
fun getPoint(t: Double, optionalTarget: E = definedExternally): E
|
||||
|
||||
fun getPointAt(u: Double, optionalTarget: E = definedExternally): E
|
||||
|
||||
fun getPoints(divisions: Int): Array<E>
|
||||
|
||||
fun getSpacedPoints(divisions: Int): Array<E>
|
||||
|
||||
fun getLength(): Double
|
||||
|
||||
fun updateArcLengths()
|
||||
|
||||
fun getUtoTmapping(u: Double, distance: Double): Double
|
||||
|
||||
fun getTangent(t: Double): E
|
||||
|
||||
fun getTangentAt(u: Double): E
|
||||
|
||||
fun computeFrenetFrames(segments: Int, closed: Boolean = definedExternally)
|
||||
|
||||
open fun clone(): Curve<E>
|
||||
|
||||
fun copy(source: Curve<E>): Curve<E>
|
||||
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
@file:JsModule("three")
|
||||
@file:JsNonModule
|
||||
|
||||
package info.laht.threekt.extras.core
|
||||
|
||||
|
||||
open external class CurvePath<E> : Curve<E> {
|
||||
|
||||
var curves: List<Curve<E>>
|
||||
|
||||
var autoClose: Boolean
|
||||
|
||||
fun add(curve: Curve<E>)
|
||||
|
||||
fun closePath()
|
||||
|
||||
fun getPoint(t: Double)
|
||||
|
||||
override fun clone(): CurvePath<E>
|
||||
|
||||
fun copy(source: CurvePath<E>): CurvePath<E>
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
@file:JsModule("three")
|
||||
@file:JsNonModule
|
||||
|
||||
package info.laht.threekt.extras.core
|
||||
|
||||
import info.laht.threekt.math.Vector2
|
||||
|
||||
open external class Path : CurvePath<Vector2> {
|
||||
|
||||
var currentPoint: Vector2
|
||||
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
@file:JsModule("three")
|
||||
@file:JsNonModule
|
||||
|
||||
package info.laht.threekt.extras.core
|
||||
|
||||
import info.laht.threekt.math.Vector2
|
||||
|
||||
external class Shape(points: Array<Vector2>) : Path
|
@ -0,0 +1,6 @@
|
||||
@file:JsModule("three")
|
||||
@file:JsNonModule
|
||||
|
||||
package info.laht.threekt.extras.core
|
||||
|
||||
external class ShapePath
|
@ -0,0 +1,20 @@
|
||||
@file:JsModule("three")
|
||||
@file:JsNonModule
|
||||
|
||||
package info.laht.threekt.extras.curves
|
||||
|
||||
external class ArcCurve(
|
||||
aX: Number = definedExternally,
|
||||
aY: Number = definedExternally,
|
||||
xRadius: Number = definedExternally,
|
||||
yRadius: Number = definedExternally,
|
||||
aStartAngle: Number = definedExternally,
|
||||
aEndAngle: Number = definedExternally,
|
||||
aClockwise: Number = definedExternally
|
||||
) : EllipseCurve {
|
||||
|
||||
override fun clone(): ArcCurve
|
||||
fun copy(curve: ArcCurve): ArcCurve
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,24 @@
|
||||
@file:JsModule("three")
|
||||
@file:JsNonModule
|
||||
|
||||
package info.laht.threekt.extras.curves
|
||||
|
||||
import info.laht.threekt.extras.core.Curve
|
||||
import info.laht.threekt.math.Vector3
|
||||
|
||||
|
||||
external class CatmullRomCurve3(
|
||||
points: Array<Vector3> = definedExternally,
|
||||
closed: Boolean = definedExternally,
|
||||
curveType: String = definedExternally,
|
||||
tension: Double = definedExternally
|
||||
) : Curve<Vector3> {
|
||||
|
||||
var points: Array<Vector3>
|
||||
var closed: Boolean
|
||||
var curveType: String
|
||||
var tension: Double
|
||||
|
||||
override fun clone(): CatmullRomCurve3
|
||||
fun copy(curve: CatmullRomCurve3): CatmullRomCurve3
|
||||
}
|
@ -0,0 +1,37 @@
|
||||
@file:JsModule("three")
|
||||
@file:JsNonModule
|
||||
|
||||
package info.laht.threekt.extras.curves
|
||||
|
||||
import info.laht.threekt.extras.core.Curve
|
||||
import info.laht.threekt.math.Vector2
|
||||
|
||||
open external class EllipseCurve(
|
||||
aX: Number = definedExternally,
|
||||
aY: Number = definedExternally,
|
||||
xRadius: Number = definedExternally,
|
||||
yRadius: Number = definedExternally,
|
||||
aStartAngle: Number = definedExternally,
|
||||
aEndAngle: Number = definedExternally,
|
||||
aClockwise: Boolean = definedExternally,
|
||||
aRotation: Number = definedExternally
|
||||
|
||||
) : Curve<Vector2> {
|
||||
|
||||
var aX: Double
|
||||
var aY: Double
|
||||
|
||||
var xRadius: Double
|
||||
var yRadius: Double
|
||||
|
||||
var aStartAngle: Double
|
||||
var aEndAngle: Double
|
||||
|
||||
var aClockwise: Boolean
|
||||
|
||||
var aRotation: Double
|
||||
|
||||
override fun clone(): EllipseCurve
|
||||
fun copy(curve: EllipseCurve): EllipseCurve
|
||||
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
@file:JsModule("three")
|
||||
@file:JsNonModule
|
||||
|
||||
package info.laht.threekt.extras.curves
|
||||
|
||||
import info.laht.threekt.extras.core.Curve
|
||||
import info.laht.threekt.math.Vector2
|
||||
|
||||
external class LineCurve(
|
||||
v1: Vector2 = definedExternally,
|
||||
v2: Vector2 = definedExternally
|
||||
) : Curve<Vector2> {
|
||||
|
||||
override fun clone(): LineCurve
|
||||
fun copy(curve: LineCurve): LineCurve
|
||||
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
@file:JsModule("three")
|
||||
@file:JsNonModule
|
||||
|
||||
package info.laht.threekt.extras.curves
|
||||
|
||||
import info.laht.threekt.extras.core.Curve
|
||||
import info.laht.threekt.math.Vector3
|
||||
|
||||
external class LineCurve3(
|
||||
v1: Vector3 = definedExternally,
|
||||
v2: Vector3 = definedExternally
|
||||
) : Curve<Vector3> {
|
||||
|
||||
override fun clone(): LineCurve3
|
||||
fun copy(curve3: LineCurve3): LineCurve3
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,21 @@
|
||||
@file:JsModule("three")
|
||||
@file:JsNonModule
|
||||
|
||||
package info.laht.threekt.extras.curves
|
||||
|
||||
import info.laht.threekt.extras.core.Curve
|
||||
import info.laht.threekt.math.Vector2
|
||||
|
||||
external class QuadricBezierCurve : Curve<Vector2> {
|
||||
|
||||
constructor(
|
||||
v0: Vector2 = definedExternally,
|
||||
v1: Vector2 = definedExternally,
|
||||
v2: Vector2 = definedExternally
|
||||
)
|
||||
|
||||
override fun clone(): QuadricBezierCurve
|
||||
fun copy(curve: QuadricBezierCurve3): QuadricBezierCurve
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,21 @@
|
||||
@file:JsModule("three")
|
||||
@file:JsNonModule
|
||||
|
||||
package info.laht.threekt.extras.curves
|
||||
|
||||
import info.laht.threekt.extras.core.Curve
|
||||
import info.laht.threekt.math.Vector3
|
||||
|
||||
external class QuadricBezierCurve3 : Curve<Vector3> {
|
||||
|
||||
constructor(
|
||||
v0: Vector3 = definedExternally,
|
||||
v1: Vector3 = definedExternally,
|
||||
v2: Vector3 = definedExternally
|
||||
)
|
||||
|
||||
override fun clone(): QuadricBezierCurve3
|
||||
fun copy(curve: QuadricBezierCurve3): QuadricBezierCurve3
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,18 @@
|
||||
@file:JsModule("three")
|
||||
@file:JsNonModule
|
||||
|
||||
package info.laht.threekt.extras.curves
|
||||
|
||||
import info.laht.threekt.extras.core.Curve
|
||||
import info.laht.threekt.math.Vector2
|
||||
|
||||
external class SplineCurve(
|
||||
points: Array<Vector2> = definedExternally
|
||||
) : Curve<Vector2> {
|
||||
|
||||
var points: Array<Vector2>
|
||||
|
||||
override fun clone(): SplineCurve
|
||||
fun copy(curve: SplineCurve): SplineCurve
|
||||
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
@file:JsModule("three")
|
||||
@file:JsNonModule
|
||||
|
||||
package info.laht.threekt.geometries
|
||||
|
||||
import info.laht.threekt.core.BufferGeometry
|
||||
import info.laht.threekt.core.Geometry
|
||||
|
||||
|
||||
external class BoxGeometry(
|
||||
width: Number,
|
||||
height: Number,
|
||||
depth: Number,
|
||||
widthSegments: Int = definedExternally,
|
||||
heightSegments: Int = definedExternally,
|
||||
depthSegments: Int = definedExternally
|
||||
) : Geometry
|
||||
|
||||
|
||||
external class BoxBufferGeometry(
|
||||
width: Number,
|
||||
height: Number,
|
||||
depth: Number,
|
||||
widthSegments: Int = definedExternally,
|
||||
heightSegments: Int = definedExternally,
|
||||
depthSegments: Int = definedExternally
|
||||
) : BufferGeometry
|
@ -0,0 +1,27 @@
|
||||
@file:JsModule("three")
|
||||
@file:JsNonModule
|
||||
|
||||
package info.laht.threekt.geometries
|
||||
|
||||
import info.laht.threekt.core.BufferGeometry
|
||||
import info.laht.threekt.core.Geometry
|
||||
|
||||
external class ConeGeometry(
|
||||
radius: Number = definedExternally,
|
||||
height: Number = definedExternally,
|
||||
radialSegments: Int = definedExternally,
|
||||
heightSegments: Int = definedExternally,
|
||||
openEnded: Boolean = definedExternally,
|
||||
thetaStart: Boolean = definedExternally,
|
||||
thetaLength: Boolean = definedExternally
|
||||
) : Geometry
|
||||
|
||||
external class ConeBufferGeometry(
|
||||
radius: Number = definedExternally,
|
||||
height: Number = definedExternally,
|
||||
radialSegments: Int = definedExternally,
|
||||
heightSegments: Int = definedExternally,
|
||||
openEnded: Boolean = definedExternally,
|
||||
thetaStart: Boolean = definedExternally,
|
||||
thetaLength: Boolean = definedExternally
|
||||
) : BufferGeometry
|
@ -0,0 +1,29 @@
|
||||
@file:JsModule("three")
|
||||
@file:JsNonModule
|
||||
|
||||
package info.laht.threekt.geometries
|
||||
|
||||
import info.laht.threekt.core.BufferGeometry
|
||||
import info.laht.threekt.core.Geometry
|
||||
|
||||
external class CylinderGeometry(
|
||||
radiusTop: Number,
|
||||
radiusBottom: Number,
|
||||
height: Number,
|
||||
radialSegments: Int = definedExternally,
|
||||
heightSegments: Int = definedExternally,
|
||||
openEnded: Boolean = definedExternally,
|
||||
thetaStart: Number = definedExternally,
|
||||
thetaLength: Number = definedExternally
|
||||
) : Geometry
|
||||
|
||||
external class CylinderBufferGeometry(
|
||||
radiusTop: Number,
|
||||
radiusBottom: Number,
|
||||
height: Number,
|
||||
radialSegments: Int = definedExternally,
|
||||
heightSegments: Int = definedExternally,
|
||||
openEnded: Boolean = definedExternally,
|
||||
thetaStart: Number = definedExternally,
|
||||
thetaLength: Number = definedExternally
|
||||
) : BufferGeometry
|
@ -0,0 +1,11 @@
|
||||
@file:JsModule("three")
|
||||
@file:JsNonModule
|
||||
|
||||
package info.laht.threekt.geometries
|
||||
|
||||
import info.laht.threekt.core.BufferGeometry
|
||||
import info.laht.threekt.core.Geometry
|
||||
|
||||
external class EdgesGeometry(geometry: Geometry, thresholdAngle: Int = definedExternally) : BufferGeometry {
|
||||
constructor(geometry: BufferGeometry, thresholdAngle: Int = definedExternally)
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
@file:JsModule("three")
|
||||
@file:JsNonModule
|
||||
|
||||
package info.laht.threekt.geometries
|
||||
|
||||
import info.laht.threekt.core.BufferGeometry
|
||||
import info.laht.threekt.core.Geometry
|
||||
|
||||
external class PlaneGeometry(
|
||||
|
||||
width: Number,
|
||||
height: Number,
|
||||
widthSegments: Int = definedExternally,
|
||||
heightSegments: Int = definedExternally
|
||||
|
||||
) : Geometry
|
||||
|
||||
external class PlaneBufferGeometry(
|
||||
|
||||
width: Number,
|
||||
height: Number,
|
||||
widthSegments: Int = definedExternally,
|
||||
heightSegments: Int = definedExternally
|
||||
|
||||
) : BufferGeometry
|
@ -0,0 +1,27 @@
|
||||
@file:JsModule("three")
|
||||
@file:JsNonModule
|
||||
|
||||
package info.laht.threekt.geometries
|
||||
|
||||
import info.laht.threekt.core.BufferGeometry
|
||||
import info.laht.threekt.core.Geometry
|
||||
|
||||
external class SphereGeometry(
|
||||
radius: Number,
|
||||
widthSegments: Int = definedExternally,
|
||||
heightSegments: Int = definedExternally,
|
||||
phiStart: Number = definedExternally,
|
||||
phiLength: Number = definedExternally,
|
||||
thetaStart: Number = definedExternally,
|
||||
thetaLength: Number = definedExternally
|
||||
) : Geometry
|
||||
|
||||
external class SphereBufferGeometry(
|
||||
radius: Number,
|
||||
widthSegments: Int = definedExternally,
|
||||
heightSegments: Int = definedExternally,
|
||||
phiStart: Number = definedExternally,
|
||||
phiLength: Number = definedExternally,
|
||||
thetaStart: Number = definedExternally,
|
||||
thetaLength: Number = definedExternally
|
||||
) : BufferGeometry
|
@ -0,0 +1,23 @@
|
||||
@file:JsModule("three")
|
||||
@file:JsNonModule
|
||||
|
||||
package info.laht.threekt.geometries
|
||||
|
||||
import info.laht.threekt.core.BufferGeometry
|
||||
import info.laht.threekt.core.Geometry
|
||||
|
||||
external class TorusGeometry(
|
||||
radius: Number = definedExternally,
|
||||
tube: Number = definedExternally,
|
||||
radialSegments: Int = definedExternally,
|
||||
tubularSegments: Int = definedExternally,
|
||||
arc: Number = definedExternally
|
||||
) : Geometry
|
||||
|
||||
external class TorusBufferGeometry(
|
||||
radius: Number = definedExternally,
|
||||
tube: Number = definedExternally,
|
||||
radialSegments: Int = definedExternally,
|
||||
tubularSegments: Int = definedExternally,
|
||||
arc: Number = definedExternally
|
||||
) : BufferGeometry
|
@ -0,0 +1,46 @@
|
||||
package info.laht.threekt.geometries
|
||||
|
||||
import info.laht.threekt.core.BufferGeometry
|
||||
import info.laht.threekt.core.Geometry
|
||||
import info.laht.threekt.extras.core.Curve
|
||||
import info.laht.threekt.math.Vector3
|
||||
|
||||
/**
|
||||
* Creates a tube that extrudes along a 3d curve.
|
||||
*/
|
||||
external class TubeGeometry(
|
||||
|
||||
path: Curve<Vector3>,
|
||||
tubularSegments: Int = definedExternally,
|
||||
radius: Number = definedExternally,
|
||||
radiusSegments: Int = definedExternally,
|
||||
closed: Boolean = definedExternally
|
||||
|
||||
) : Geometry {
|
||||
|
||||
var tangents: Array<Vector3>
|
||||
var normals: Array<Vector3>
|
||||
var binormals: Array<Vector3>
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a tube that extrudes along a 3d curve.
|
||||
*/
|
||||
external class TubeBufferGeometry(
|
||||
|
||||
path: Curve<Vector3>,
|
||||
tubularSegments: Int = definedExternally,
|
||||
radius: Number = definedExternally,
|
||||
radiusSegments: Int = definedExternally,
|
||||
closed: Boolean = definedExternally
|
||||
|
||||
) : BufferGeometry {
|
||||
|
||||
val parameters: dynamic
|
||||
|
||||
val tangents: Array<Vector3>
|
||||
val normals: Array<Vector3>
|
||||
val binormals: Array<Vector3>
|
||||
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
@file:JsModule("three")
|
||||
@file:JsNonModule
|
||||
|
||||
package info.laht.threekt.geometries
|
||||
|
||||
import info.laht.threekt.core.BufferGeometry
|
||||
import info.laht.threekt.core.Geometry
|
||||
|
||||
/**
|
||||
* This can be used as a helper object to view a Geometry object as a wireframe.
|
||||
*/
|
||||
external class WireframeGeometry : BufferGeometry {
|
||||
|
||||
constructor(geometry: Geometry)
|
||||
constructor(geometry: BufferGeometry)
|
||||
|
||||
}
|
@ -0,0 +1,54 @@
|
||||
/*
|
||||
* The MIT License
|
||||
*
|
||||
* Copyright 2017-2018 Lars Ivar Hatledal
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
@file:JsModule("three")
|
||||
@file:JsNonModule
|
||||
|
||||
package info.laht.threekt.helpers
|
||||
|
||||
import info.laht.threekt.core.Object3D
|
||||
import info.laht.threekt.math.Color
|
||||
import info.laht.threekt.math.Vector3
|
||||
import info.laht.threekt.objects.Line
|
||||
import info.laht.threekt.objects.Mesh
|
||||
|
||||
external class ArrowHelper(
|
||||
dir: Vector3,
|
||||
origin: Vector3,
|
||||
length: Number,
|
||||
color: Int = definedExternally,
|
||||
headLength: Number = definedExternally,
|
||||
headWidth: Number = definedExternally
|
||||
) : Object3D {
|
||||
|
||||
var line: Line
|
||||
|
||||
var cone: Mesh
|
||||
|
||||
fun setDirection(dir: Vector3)
|
||||
fun setLength(length: Number, headLength: Number, headWidth: Number)
|
||||
|
||||
fun setColor(color: Color)
|
||||
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
/*
|
||||
* The MIT License
|
||||
*
|
||||
* Copyright 2017-2018 Lars Ivar Hatledal
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
@file:JsModule("three")
|
||||
@file:JsNonModule
|
||||
|
||||
package info.laht.threekt.helpers
|
||||
|
||||
import info.laht.threekt.objects.LineSegments
|
||||
|
||||
external class AxesHelper(
|
||||
size: Int = definedExternally
|
||||
) : LineSegments
|
@ -0,0 +1,49 @@
|
||||
/*
|
||||
* The MIT License
|
||||
*
|
||||
* Copyright 2017-2018 Lars Ivar Hatledal
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
@file:JsModule("three")
|
||||
@file:JsNonModule
|
||||
|
||||
package info.laht.threekt.helpers
|
||||
|
||||
import info.laht.threekt.math.Box3
|
||||
import info.laht.threekt.objects.LineSegments
|
||||
|
||||
/**
|
||||
* Helper object to visualize a Box3.
|
||||
*
|
||||
* @param box the Box3 to show.
|
||||
* @param color (optional) the box's color. Default is 0xffff00.
|
||||
*/
|
||||
external class Box3Helper(
|
||||
box: Box3,
|
||||
color: Int = definedExternally
|
||||
) : LineSegments {
|
||||
|
||||
/**
|
||||
* The Box3 being visualized.
|
||||
*/
|
||||
var box: Box3
|
||||
|
||||
}
|
@ -0,0 +1,43 @@
|
||||
/*
|
||||
* The MIT License
|
||||
*
|
||||
* Copyright 2017-2018 Lars Ivar Hatledal
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
@file:JsModule("three")
|
||||
@file:JsNonModule
|
||||
|
||||
package info.laht.threekt.helpers
|
||||
|
||||
import info.laht.threekt.cameras.Camera
|
||||
import info.laht.threekt.objects.LineSegments
|
||||
|
||||
external class CameraHelper(
|
||||
camera: Camera
|
||||
) : LineSegments {
|
||||
|
||||
|
||||
var camera: Camera
|
||||
|
||||
fun update()
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,38 @@
|
||||
/*
|
||||
* The MIT License
|
||||
*
|
||||
* Copyright 2017-2018 Lars Ivar Hatledal
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
@file:JsModule("three")
|
||||
@file:JsNonModule
|
||||
|
||||
package info.laht.threekt.helpers
|
||||
|
||||
import info.laht.threekt.objects.LineSegments
|
||||
|
||||
external class GridHelper(
|
||||
size: Int = definedExternally,
|
||||
divisions: Int = definedExternally,
|
||||
color1: Int = definedExternally,
|
||||
color2: Int = definedExternally
|
||||
) : LineSegments
|
||||
|
@ -0,0 +1,51 @@
|
||||
/*
|
||||
* The MIT License
|
||||
*
|
||||
* Copyright 2017-2018 Lars Ivar Hatledal
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
@file:JsModule("three")
|
||||
@file:JsNonModule
|
||||
|
||||
package info.laht.threekt.helpers
|
||||
|
||||
import info.laht.threekt.core.Object3D
|
||||
import info.laht.threekt.lights.HemiSphereLight
|
||||
import info.laht.threekt.lights.Light
|
||||
|
||||
/**
|
||||
* Creates a visual aid consisting of a spherical Mesh for a HemisphereLight.
|
||||
*
|
||||
* @param light The light being visualized.
|
||||
* @param size The size of the mesh used to visualize the light.
|
||||
* @param color (optional) if this is not the set the helper will take the color of the light.
|
||||
*/
|
||||
external class HemisphereLightHelper(
|
||||
light: HemiSphereLight,
|
||||
size: Number,
|
||||
color: Int = definedExternally
|
||||
) : Object3D {
|
||||
|
||||
var light: Light
|
||||
|
||||
fun dispose()
|
||||
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
@file:Suppress("FunctionName")
|
||||
|
||||
package info.laht.threekt
|
||||
|
||||
import info.laht.threekt.renderers.WebGLRenderer
|
||||
import info.laht.threekt.renderers.WebGLRendererParams
|
||||
|
||||
fun WebGLRenderer(builder: WebGLRendererParams.() -> Unit): WebGLRenderer =
|
||||
WebGLRenderer(WebGLRendererParams().apply(builder))
|
@ -0,0 +1,39 @@
|
||||
/*
|
||||
* The MIT License
|
||||
*
|
||||
* Copyright 2017-2018 Lars Ivar Hatledal
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
@file:JsModule("three")
|
||||
@file:JsNonModule
|
||||
|
||||
package info.laht.threekt.lights
|
||||
|
||||
/**
|
||||
* This light globally illuminates all objects in the scene equally.
|
||||
*
|
||||
* This light cannot be used to cast shadows as it does not have a direction.
|
||||
*/
|
||||
|
||||
external class AmbientLight(
|
||||
color: Int = definedExternally,
|
||||
intensity: Number = definedExternally
|
||||
) : Light
|
@ -0,0 +1,41 @@
|
||||
/*
|
||||
* The MIT License
|
||||
*
|
||||
* Copyright 2017-2018 Lars Ivar Hatledal
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
@file:JsModule("three")
|
||||
@file:JsNonModule
|
||||
|
||||
package info.laht.threekt.lights
|
||||
|
||||
import info.laht.threekt.core.Object3D
|
||||
|
||||
external class DirectionalLight(
|
||||
color: Int = definedExternally,
|
||||
intensity: Number = definedExternally
|
||||
) : Light {
|
||||
|
||||
var target: Object3D
|
||||
|
||||
var shadow: DirectionalLightShadow
|
||||
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
/*
|
||||
* The MIT License
|
||||
*
|
||||
* Copyright 2017-2018 Lars Ivar Hatledal
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
@file:JsModule("three")
|
||||
@file:JsNonModule
|
||||
|
||||
package info.laht.threekt.lights
|
||||
|
||||
external class DirectionalLightShadow : LightShadow {
|
||||
|
||||
}
|
@ -0,0 +1,47 @@
|
||||
/*
|
||||
* The MIT License
|
||||
*
|
||||
* Copyright 2017-2018 Lars Ivar Hatledal
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
@file:JsModule("three")
|
||||
@file:JsNonModule
|
||||
|
||||
package info.laht.threekt.lights
|
||||
|
||||
import info.laht.threekt.math.Color
|
||||
|
||||
/**
|
||||
* A light source positioned directly above the scene, with color fading from the sky color to the ground color.
|
||||
*
|
||||
* This light cannot be used to cast shadows.
|
||||
*/
|
||||
external class HemiSphereLight(
|
||||
skyColor: Int = definedExternally,
|
||||
groundColor: Int = definedExternally,
|
||||
intensity: Number = definedExternally
|
||||
) : Light {
|
||||
|
||||
var groundColor: Color
|
||||
|
||||
fun copy(light: HemiSphereLight): HemiSphereLight
|
||||
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user