{"version":3,"sources":["jsdelivr-header.js","/npm/@thi.ng/scenegraph@2.0.41/anode.js","/npm/@thi.ng/scenegraph@2.0.41/hiccup.js","/npm/@thi.ng/scenegraph@2.0.41/node2.js","/npm/@thi.ng/scenegraph@2.0.41/node3.js"],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA,22BCJA,MAAM,EACJ,GACA,OACA,SACA,KACA,IACA,OACA,QACA,QACA,WAAA,EAAY,GACV,EAAE,OACF,EAAM,KACN,EAAI,QACJ,GAAU,EAAI,QACd,GAAU,IAEV,KAAK,GAAK,EACV,KAAK,OAAS,EACd,KAAK,SAAW,GACZ,GACF,EAAO,YAAY,MAErB,KAAK,KAAO,EACZ,KAAK,IAAM,GACX,KAAK,OAAS,GACd,KAAK,QAAU,EACf,KAAK,QAAU,CACnB,CACE,WAAA,CAAY,GAEV,OADA,KAAK,SAAS,KAAK,GACZ,IACX,CACE,WAAA,CAAY,EAAG,GACb,MAAM,EAAW,KAAK,SAMtB,OALA,EAAI,IAAM,GAAK,EAAS,QACxB,EAAO,GAAK,GAAK,GAAK,EAAS,OAAQ,uBACvC,EAAS,OAAO,EAAG,EAAG,GACtB,EAAK,OAAS,KACd,EAAK,SACE,IACX,CACE,WAAA,CAAY,GACV,MAAM,SAAE,GAAa,KACf,EAAI,EAAS,GAAQ,EAAO,EAAS,QAAQ,GACnD,OAAI,GAAK,GAAK,EAAI,EAAS,SACzB,EAAS,OAAO,EAAG,IACZ,EAGb,CACE,IAAA,CAAK,GACH,GAAI,KAAK,QACP,IAAK,MAAM,KAAK,KAAK,SACnB,EAAE,KAAK,EAGf,CACE,aAAA,CAAc,GACZ,GAAI,KAAK,QAAS,CAChB,MAAM,EAAW,KAAK,SACtB,IAAK,IAAI,EAAI,EAAS,OAAQ,KAAM,GAAK,CACvC,MAAM,EAAI,EAAS,GAAG,cAAc,GACpC,GAAI,EACF,OAAO,CAEjB,CACM,MAAM,EAAI,KAAK,eAAe,GAC9B,GAAI,GAAK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,EAAM,GACxB,OAAO,EAAQ,KAAM,EAAK,OAAQ,EAAQ,GAAI,KAAK,IAAK,GAC5D,CACE,uBAAA,CAAwB,EAAK,GAC3B,GAAI,KAAK,QAAS,CAChB,MAAM,EAAY,EAAS,KAAK,OAAS,EAAM,GAAI,KAAK,OAAS,KAAK,MAChE,EAAW,EAAS,GAAS,EAAM,GAAI,GAAS,EAChD,EAAQ,EAAK,GAAI,EAAW,GAClC,KAAK,MAAQ,EACb,KAAK,UAAY,EAAM,GAAI,EAAK,EAAO,KAAK,WAC5C,KAAK,QACX,CACI,OAAO,IACX,CAOE,QAAA,CAAS,GACP,OAAO,EAAS,KAAM,EAC1B,S","file":"/npm/@thi.ng/scenegraph@2.0.41/index.js/+esm","sourceRoot":"","sourcesContent":["/**\n * Bundled by jsDelivr using Rollup v2.79.2 and Terser v5.39.0.\n * Original file: /npm/@thi.ng/scenegraph@2.0.41/index.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","import { isNumber } from \"@thi.ng/checks/is-number\";\nimport { assert } from \"@thi.ng/errors/assert\";\nclass ANode {\n  id;\n  parent;\n  children;\n  body;\n  mat;\n  invMat;\n  enabled;\n  display;\n  constructor({\n    id,\n    parent,\n    body,\n    enabled = true,\n    display = true\n  }) {\n    this.id = id;\n    this.parent = parent;\n    this.children = [];\n    if (parent) {\n      parent.appendChild(this);\n    }\n    this.body = body;\n    this.mat = [];\n    this.invMat = [];\n    this.enabled = enabled;\n    this.display = display;\n  }\n  appendChild(node) {\n    this.children.push(node);\n    return this;\n  }\n  insertChild(i, node) {\n    const children = this.children;\n    i < 0 && (i += children.length);\n    assert(i >= 0 && i <= children.length, \"index out of bounds\");\n    children.splice(i, 0, node);\n    node.parent = this;\n    node.update();\n    return this;\n  }\n  deleteChild(node) {\n    const { children } = this;\n    const i = isNumber(node) ? node : children.indexOf(node);\n    if (i >= 0 && i < children.length) {\n      children.splice(i, 1);\n      return true;\n    }\n    return false;\n  }\n  draw(ctx) {\n    if (this.display) {\n      for (const c of this.children) {\n        c.draw(ctx);\n      }\n    }\n  }\n  childForPoint(p) {\n    if (this.enabled) {\n      const children = this.children;\n      for (let i = children.length; i-- > 0; ) {\n        const n = children[i].childForPoint(p);\n        if (n) {\n          return n;\n        }\n      }\n      const q = this.mapGlobalPoint(p);\n      if (q && this.containsLocalPoint(q)) {\n        return { node: this, p: q };\n      }\n    }\n  }\n  containsLocalPoint(_) {\n    return false;\n  }\n}\nexport {\n  ANode\n};\n","import { deref } from \"@thi.ng/api/deref\";\nimport { isFunction } from \"@thi.ng/checks/is-function\";\nconst toHiccup = (node, ctx) => {\n  const body = isFunction(node.body) ? node.body(ctx) : deref(node.body);\n  return node.enabled && node.display ? node.children.length ? [\n    \"g\",\n    {},\n    node.body ? [\"g\", { transform: node.mat }, body] : void 0,\n    ...node.children.map((c) => c.toHiccup(ctx))\n  ] : body ? [\"g\", { transform: node.mat }, body] : void 0 : void 0;\n};\nexport {\n  toHiccup\n};\n","import { isNumber } from \"@thi.ng/checks/is-number\";\nimport { invert23 } from \"@thi.ng/matrices/invert\";\nimport { mulM23 } from \"@thi.ng/matrices/mulm\";\nimport { mulV23 } from \"@thi.ng/matrices/mulv\";\nimport { transform23 } from \"@thi.ng/matrices/transform\";\nimport { madd2 } from \"@thi.ng/vectors/madd\";\nimport { set2 } from \"@thi.ng/vectors/set\";\nimport { setN2 } from \"@thi.ng/vectors/setn\";\nimport { sub2 } from \"@thi.ng/vectors/sub\";\nimport { ANode } from \"./anode.js\";\nimport { toHiccup } from \"./hiccup.js\";\nclass Node2D extends ANode {\n  translate;\n  rotate;\n  scale;\n  constructor(opts) {\n    super(opts);\n    this.translate = opts.translate ?? [0, 0];\n    this.rotate = opts.rotate ?? 0;\n    const scale = opts.scale ?? 1;\n    this.scale = isNumber(scale) ? [scale, scale] : scale;\n    this.update();\n  }\n  copy() {\n    return new Node2D({\n      id: this.id,\n      parent: this.parent,\n      translate: set2([], this.translate),\n      rotate: this.rotate,\n      scale: set2([], this.scale),\n      body: this.body\n    });\n  }\n  update() {\n    if (this.enabled) {\n      this.mat = transform23([], this.translate, this.rotate, this.scale);\n      if (this.parent) {\n        mulM23(this.mat, this.parent.mat, this.mat);\n      }\n      invert23(this.invMat, this.mat);\n      for (const c of this.children) {\n        c.update();\n      }\n    }\n  }\n  mapGlobalPoint(p) {\n    return mulV23([], this.invMat, p);\n  }\n  mapLocalPointToGlobal(p) {\n    return mulV23([], this.mat, p);\n  }\n  mapLocalPointToNode(dest, p) {\n    return mulV23(null, dest.invMat, mulV23([], this.mat, p));\n  }\n  scaleWithReferencePoint(ref, scale) {\n    if (this.enabled) {\n      const currScale = isNumber(this.scale) ? setN2([], this.scale) : this.scale;\n      const newScale = isNumber(scale) ? setN2([], scale) : scale;\n      const delta = sub2([], currScale, newScale);\n      this.scale = newScale;\n      this.translate = madd2([], ref, delta, this.translate);\n      this.update();\n    }\n    return this;\n  }\n  /**\n   * By implementing this method (`IToHiccup` interface), scene graph nodes\n   * can be directly used by hdom-canvas, hiccup-canvas, rdom-canvas or\n   * hiccup-svg (for the latter one needs to call `convertTree()` first).\n   *\n   * @param ctx - arbitrary user data\n   */\n  toHiccup(ctx) {\n    return toHiccup(this, ctx);\n  }\n}\nexport {\n  Node2D\n};\n","import { isNumber } from \"@thi.ng/checks/is-number\";\nimport { invert44 } from \"@thi.ng/matrices/invert\";\nimport { mulM44 } from \"@thi.ng/matrices/mulm\";\nimport { mulV344 } from \"@thi.ng/matrices/mulv\";\nimport { transform44 } from \"@thi.ng/matrices/transform\";\nimport { madd3 } from \"@thi.ng/vectors/madd\";\nimport { set3 } from \"@thi.ng/vectors/set\";\nimport { setN3 } from \"@thi.ng/vectors/setn\";\nimport { sub3 } from \"@thi.ng/vectors/sub\";\nimport { ANode } from \"./anode.js\";\nimport { toHiccup } from \"./hiccup.js\";\nclass Node3D extends ANode {\n  translate;\n  rotate;\n  scale;\n  constructor(opts) {\n    super(opts);\n    this.translate = opts.translate ?? [0, 0, 0];\n    this.rotate = opts.rotate ?? [0, 0, 0];\n    const scale = opts.scale ?? 1;\n    this.scale = isNumber(scale) ? [scale, scale, scale] : scale;\n    this.update();\n  }\n  copy() {\n    return new Node3D({\n      id: this.id,\n      parent: this.parent,\n      translate: set3([], this.translate),\n      rotate: set3([], this.rotate),\n      scale: set3([], this.scale),\n      body: this.body\n    });\n  }\n  update() {\n    if (this.enabled) {\n      this.mat = transform44([], this.translate, this.rotate, this.scale);\n      if (this.parent) {\n        mulM44(this.mat, this.parent.mat, this.mat);\n      }\n      invert44(this.invMat, this.mat);\n      for (const c of this.children) {\n        c.update();\n      }\n    }\n  }\n  mapGlobalPoint(p) {\n    return mulV344([], this.invMat, p);\n  }\n  mapLocalPointToGlobal(p) {\n    return mulV344([], this.mat, p);\n  }\n  mapLocalPointToNode(dest, p) {\n    return mulV344(null, dest.invMat, mulV344([], this.mat, p));\n  }\n  scaleWithReferencePoint(ref, scale) {\n    if (this.enabled) {\n      const currScale = isNumber(this.scale) ? setN3([], this.scale) : this.scale;\n      const newScale = isNumber(scale) ? setN3([], scale) : scale;\n      const delta = sub3([], currScale, newScale);\n      this.scale = newScale;\n      this.translate = madd3([], ref, delta, this.translate);\n      this.update();\n    }\n    return this;\n  }\n  /**\n   * Future support planned. No immediate users of this method in a 3D context\n   * available thus far.\n   *\n   * @param ctx - arbitrary user data\n   */\n  toHiccup(ctx) {\n    return toHiccup(this, ctx);\n  }\n}\nexport {\n  Node3D\n};\n"]}