var test = function(exports, mxdraw, mxcad2, vue, axios2) {
var __vite_style__ = document.createElement("style");
__vite_style__.textContent = ".heading[data-v-9bd7093d] {\n font-size: 1.5em;\n margin-bottom: 12px;\n}\n.card[data-v-9bd7093d] {\n background: #fff;\n color: #000;\n background-image: linear-gradient(48deg, #fff 0%, #e5efe9 100%);\n border-top-right-radius: 16px;\n border-bottom-left-radius: 16px;\n box-shadow: -20px 20px 35px 1px rgba(10, 49, 86, 0.18);\n display: flex;\n flex-direction: column;\n padding: 32px;\n margin: 40px;\n max-width: 400px;\n width: 100%;\n}\n.content-wrapper[data-v-9bd7093d] {\n font-size: 1.1em;\n margin-bottom: 44px;\n}\n.content-wrapper[data-v-9bd7093d]:last-child {\n margin-bottom: 0;\n}\n.button[data-v-9bd7093d] {\n align-items: center;\n background: #e5efe9;\n border: 1px solid #5a72b5;\n border-radius: 4px;\n color: #121943;\n cursor: pointer;\n display: flex;\n font-size: 1em;\n font-weight: 700;\n height: 40px;\n justify-content: center;\n width: 180px;\n}\n.button[data-v-9bd7093d]:focus {\n border: 2px solid transparent;\n box-shadow: 0px 0px 0px 2px #121943;\n outline: solid 4px transparent;\n}\n.link[data-v-9bd7093d] {\n color: #121943;\n}\n.link[data-v-9bd7093d]:focus {\n box-shadow: 0px 0px 0px 2px #121943;\n}\n.input-wrapper[data-v-9bd7093d] {\n display: flex;\n flex-direction: column;\n}\n.input-wrapper .label[data-v-9bd7093d] {\n align-items: baseline;\n display: flex;\n font-weight: 700;\n justify-content: space-between;\n margin-bottom: 8px;\n}\n.input-wrapper .optional[data-v-9bd7093d] {\n color: #5a72b5;\n font-size: 0.9em;\n}\n.input-wrapper .input[data-v-9bd7093d] {\n border: 1px solid #5a72b5;\n border-radius: 4px;\n height: 40px;\n padding: 8px;\n}\ncode[data-v-9bd7093d] {\n background: #e5efe9;\n border: 1px solid #5a72b5;\n border-radius: 4px;\n padding: 2px 4px;\n}\n.modal-header[data-v-9bd7093d] {\n align-items: baseline;\n display: flex;\n justify-content: space-between;\n}\n.close[data-v-9bd7093d] {\n background: none;\n border: none;\n cursor: pointer;\n display: flex;\n height: 16px;\n text-decoration: none;\n width: 16px;\n}\n.close svg[data-v-9bd7093d] {\n width: 16px;\n}\n.modal-wrapper[data-v-9bd7093d] {\n align-items: center;\n background: rgba(0, 0, 0, 0.7);\n bottom: 0;\n display: flex;\n justify-content: center;\n left: 0;\n position: fixed;\n right: 0;\n top: 0;\n}\n#modal[data-v-9bd7093d] {\n transition: opacity 0.25s ease-in-out;\n}\n#modal .modal-body[data-v-9bd7093d] {\n max-width: 830px;\n opacity: 1;\n transform: translateY(-100px);\n transition: opacity 0.25s ease-in-out;\n width: 100%;\n z-index: 1;\n}\n.outside-trigger[data-v-9bd7093d] {\n bottom: 0;\n cursor: default;\n left: 0;\n position: fixed;\n right: 0;\n top: 0;\n}\n.button__link[data-v-9bd7093d] {\n text-decoration: none;\n}\n.button[data-v-9bd7093d] {\n background-color: #4caf50;\n /* Green */\n border: none;\n color: white;\n text-align: center;\n text-decoration: none;\n display: inline-block;\n font-size: 16px;\n margin: 4px 2px;\n -webkit-transition-duration: 0.4s;\n /* Safari */\n transition-duration: 0.4s;\n cursor: pointer;\n}\n.button1[data-v-9bd7093d] {\n background-color: white;\n color: black;\n border: 2px solid #4caf50;\n}\n.button1[data-v-9bd7093d]:hover {\n background-color: #4caf50;\n color: white;\n}\n.button2[data-v-9bd7093d] {\n background-color: white;\n color: black;\n border: 2px solid #008cba;\n}\n.button2[data-v-9bd7093d]:hover {\n background-color: #008cba;\n color: white;\n}\n.btn_box[data-v-9bd7093d] {\n width: 100%;\n display: flex;\n justify-items: center;\n justify-content: start;\n align-items: start;\n}";
document.head.appendChild(__vite_style__);
"use strict";var __pow = Math.pow;
var __async = (__this, __arguments, generator) => {
return new Promise((resolve, reject) => {
var fulfilled = (value) => {
try {
step(generator.next(value));
} catch (e) {
reject(e);
}
};
var rejected = (value) => {
try {
step(generator.throw(value));
} catch (e) {
reject(e);
}
};
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
step((generator = generator.apply(__this, __arguments)).next());
});
};
const isModalVisible = vue.ref(false);
const showModal$1 = (options) => {
isModalVisible.value = true;
modalOptions.value = Object.assign(modalOptions.value, options || {});
};
const hideModal$1 = () => {
isModalVisible.value = false;
};
const modalOpts = {
title: "Modal",
text: "",
oncancel: hideModal$1,
onsubmit: hideModal$1,
ongetallentity: hideModal$1,
ondrawline: hideModal$1,
docommand: (cmd) => {
}
};
const modalOptions = vue.ref(modalOpts);
const useModalVisible = () => {
return {
isModalVisible,
showModal: showModal$1,
hideModal: hideModal$1,
modalOptions
};
};
const _withScopeId = (n) => (vue.pushScopeId("data-v-9bd7093d"), n = n(), vue.popScopeId(), n);
const _hoisted_1 = {
key: 0,
class: "modal-wrapper",
id: "modal"
};
const _hoisted_2 = { class: "modal-body card" };
const _hoisted_3 = { class: "modal-header" };
const _hoisted_4 = { class: "heading" };
const _hoisted_5 = /* @__PURE__ */ _withScopeId(() => /* @__PURE__ */ vue.createElementVNode("svg", { viewBox: "0 0 24 24" }, [
/* @__PURE__ */ vue.createElementVNode("path", { d: "M24 20.188l-8.315-8.209 8.2-8.282-3.697-3.697-8.212 8.318-8.31-8.203-3.666 3.666 8.321 8.24-8.206 8.313 3.666 3.666 8.237-8.318 8.285 8.203z" })
], -1));
const _hoisted_6 = [
_hoisted_5
];
const _hoisted_7 = { style: { "overflow-y": "auto", "height": "500px" } };
const _hoisted_8 = { class: "btn_box" };
const _hoisted_9 = { class: "btn_box" };
const _hoisted_10 = { class: "btn_box" };
const _hoisted_11 = { class: "btn_box" };
const _hoisted_12 = { class: "btn_box" };
const _hoisted_13 = { class: "btn_box" };
const _hoisted_14 = { class: "btn_box" };
const _hoisted_15 = { class: "btn_box" };
const _hoisted_16 = { class: "btn_box" };
const _hoisted_17 = { class: "btn_box" };
const _hoisted_18 = { class: "btn_box" };
const _hoisted_19 = { class: "btn_box" };
const _hoisted_20 = { class: "btn_box" };
const _hoisted_21 = { class: "btn_box" };
const _sfc_main$1 = /* @__PURE__ */ vue.defineComponent({
__name: "Modal",
setup(__props) {
const { isModalVisible: isModalVisible2, hideModal: hideModal2, modalOptions: modalOptions2 } = useModalVisible();
hideModal2();
return (_ctx, _cache) => {
return vue.openBlock(), vue.createBlock(vue.Teleport, { to: "body" }, [
vue.createTextVNode(" 2356788909-80976564578697809-090897867 "),
vue.unref(isModalVisible2) ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_1, [
vue.createElementVNode("div", _hoisted_2, [
vue.createElementVNode("div", _hoisted_3, [
vue.createElementVNode("h2", _hoisted_4, vue.toDisplayString(vue.unref(modalOptions2).title), 1),
vue.createElementVNode("a", {
href: "#!",
onClick: _cache[0] || (_cache[0] = //@ts-ignore
(...args) => vue.unref(hideModal2) && vue.unref(hideModal2)(...args)),
role: "button",
class: "close",
"aria-label": "close this modal"
}, _hoisted_6)
]),
vue.createElementVNode("div", _hoisted_7, [
vue.createElementVNode("div", _hoisted_8, [
vue.createElementVNode("button", {
class: "button button2",
onClick: _cache[1] || (_cache[1] = ($event) => vue.unref(modalOptions2).docommand("Mx_Open_DemoCode"))
}, " 下载开Demo代码 "),
vue.createElementVNode("button", {
class: "button button2",
onClick: _cache[2] || (_cache[2] = ($event) => vue.unref(modalOptions2).docommand("Mx_Open_DevInstall"))
}, " 下载开发包 "),
vue.createElementVNode("button", {
class: "button button2",
onClick: _cache[3] || (_cache[3] = //@ts-ignore
(...args) => vue.unref(modalOptions2).ondrawline && vue.unref(modalOptions2).ondrawline(...args))
}, " 调用画圆线命令 "),
vue.createElementVNode("button", {
class: "button button2",
onClick: _cache[4] || (_cache[4] = ($event) => vue.unref(modalOptions2).docommand("MxTest_DrawLine"))
}, " 交互画直线 ")
]),
vue.createElementVNode("div", _hoisted_9, [
vue.createElementVNode("button", {
class: "button button2",
onClick: _cache[5] || (_cache[5] = ($event) => vue.unref(modalOptions2).docommand("MxTest_AddLayer"))
}, " 添加图层 "),
vue.createElementVNode("button", {
class: "button button2",
onClick: _cache[6] || (_cache[6] = ($event) => vue.unref(modalOptions2).docommand("MxTest_GetAllLayer"))
}, " 得到所有图层 "),
vue.createElementVNode("button", {
class: "button button2",
onClick: _cache[7] || (_cache[7] = ($event) => vue.unref(modalOptions2).docommand("MxTest_GetAllTextStyle"))
}, " 得到所有文字样式 "),
vue.createElementVNode("button", {
class: "button button2",
onClick: _cache[8] || (_cache[8] = ($event) => vue.unref(modalOptions2).docommand("MxTest_GetAllBlock"))
}, " 得到所有图块 ")
]),
vue.createElementVNode("div", _hoisted_10, [
vue.createElementVNode("button", {
class: "button button2",
onClick: _cache[9] || (_cache[9] = ($event) => vue.unref(modalOptions2).docommand("MxTest_GetAllLinetype"))
}, " 得到所有线型 "),
vue.createElementVNode("button", {
class: "button button2",
onClick: _cache[10] || (_cache[10] = ($event) => vue.unref(modalOptions2).docommand("MxTest_WritexData"))
}, " 写扩展数据 "),
vue.createElementVNode("button", {
class: "button button2",
onClick: _cache[11] || (_cache[11] = ($event) => vue.unref(modalOptions2).docommand("MxTest_ReadxData"))
}, " 读扩展数据 "),
vue.createElementVNode("button", {
class: "button button2",
onClick: _cache[12] || (_cache[12] = ($event) => vue.unref(modalOptions2).docommand("MxTest_InsertBlock"))
}, " 测试插入一个图块 ")
]),
vue.createElementVNode("div", _hoisted_11, [
vue.createElementVNode("button", {
class: "button button2",
onClick: _cache[13] || (_cache[13] = ($event) => vue.unref(modalOptions2).docommand("Mx_Test_DrawLine"))
}, " 绘直线 "),
vue.createElementVNode("button", {
class: "button button2",
onClick: _cache[14] || (_cache[14] = ($event) => vue.unref(modalOptions2).docommand("Mx_Test_DrawArc"))
}, " 绘圆弧 "),
vue.createElementVNode("button", {
class: "button button2",
onClick: _cache[15] || (_cache[15] = ($event) => vue.unref(modalOptions2).docommand("Mx_Test_DrawCircle"))
}, " 绘圆 "),
vue.createElementVNode("button", {
class: "button button2",
onClick: _cache[16] || (_cache[16] = ($event) => vue.unref(modalOptions2).docommand("Mx_Test_DrawPolyline"))
}, " 绘PL线 ")
]),
vue.createElementVNode("div", _hoisted_12, [
vue.createElementVNode("button", {
class: "button button2",
onClick: _cache[17] || (_cache[17] = ($event) => vue.unref(modalOptions2).docommand("Mx_Test_DrawHatch"))
}, " 绘填充 "),
vue.createElementVNode("button", {
class: "button button2",
onClick: _cache[18] || (_cache[18] = ($event) => vue.unref(modalOptions2).docommand("Mx_Test_DrawText"))
}, " 绘文字 "),
vue.createElementVNode("button", {
class: "button button2",
onClick: _cache[19] || (_cache[19] = ($event) => vue.unref(modalOptions2).docommand("Mx_Test_Ellipse"))
}, " 绘椭圆 "),
vue.createElementVNode("button", {
class: "button button2",
onClick: _cache[20] || (_cache[20] = ($event) => vue.unref(modalOptions2).docommand("Mx_Test_EllipseArc"))
}, " 绘椭圆弧 ")
]),
vue.createElementVNode("div", _hoisted_13, [
vue.createElementVNode("button", {
class: "button button2",
onClick: _cache[21] || (_cache[21] = ($event) => vue.unref(modalOptions2).docommand("Mx_Test_MText"))
}, " 绘制多行文字 "),
vue.createElementVNode("button", {
class: "button button2",
onClick: _cache[22] || (_cache[22] = ($event) => vue.unref(modalOptions2).docommand("Mx_Test_DrawTable"))
}, " 绘制表格 "),
vue.createElementVNode("button", {
class: "button button2",
onClick: _cache[23] || (_cache[23] = ($event) => vue.unref(modalOptions2).docommand("Mx_Test_QRCode"))
}, " 绘制二维码 "),
vue.createElementVNode("button", {
class: "button button2",
onClick: _cache[24] || (_cache[24] = ($event) => vue.unref(modalOptions2).docommand("MxTest_InsertStamp"))
}, " 插入图章 ")
]),
vue.createElementVNode("div", _hoisted_14, [
vue.createElementVNode("button", {
class: "button button2",
onClick: _cache[25] || (_cache[25] = //@ts-ignore
(...args) => vue.unref(modalOptions2).ongetallentity && vue.unref(modalOptions2).ongetallentity(...args))
}, " 得到所有对象 "),
vue.createElementVNode("button", {
class: "button button2",
onClick: _cache[26] || (_cache[26] = ($event) => vue.unref(modalOptions2).docommand("MxTest_SelectEntity"))
}, " 交互选择对象 "),
vue.createElementVNode("button", {
class: "button button2",
onClick: _cache[27] || (_cache[27] = ($event) => vue.unref(modalOptions2).docommand("Mx_Export_MxWeb"))
}, " 保存mxweb到服务器 "),
vue.createElementVNode("button", {
class: "button button2",
onClick: _cache[28] || (_cache[28] = ($event) => vue.unref(modalOptions2).docommand("MxTest_GetSysVars"))
}, " 得到系统变量 ")
]),
vue.createElementVNode("div", _hoisted_15, [
vue.createElementVNode("button", {
class: "button button2",
onClick: _cache[29] || (_cache[29] = ($event) => vue.unref(modalOptions2).docommand("MxTest_NewFile"))
}, " 新建图纸 "),
vue.createElementVNode("button", {
class: "button button2",
onClick: _cache[30] || (_cache[30] = ($event) => vue.unref(modalOptions2).docommand("Mx_ViewBackgroundColor"))
}, " 白色背景色 "),
vue.createElementVNode("button", {
class: "button button2",
onClick: _cache[31] || (_cache[31] = ($event) => vue.unref(modalOptions2).docommand("MxTest_FindText"))
}, " 文字查找定位 "),
vue.createElementVNode("button", {
class: "button button2",
onClick: _cache[32] || (_cache[32] = ($event) => vue.unref(modalOptions2).docommand("MxTest_SelectEntitysToBlock"))
}, " 选择实体做块 ")
]),
vue.createElementVNode("div", _hoisted_16, [
vue.createElementVNode("button", {
class: "button button2",
onClick: _cache[33] || (_cache[33] = ($event) => vue.unref(modalOptions2).docommand("Mx_Test_Text"))
}, " 绘制单行文字 "),
vue.createElementVNode("button", {
class: "button button2",
onClick: _cache[34] || (_cache[34] = ($event) => vue.unref(modalOptions2).docommand("MxTest_DrawHatchFormPoint"))
}, " 选点填充 "),
vue.createElementVNode("button", {
class: "button button2",
onClick: _cache[35] || (_cache[35] = ($event) => vue.unref(modalOptions2).docommand("Mx_TestExProp"))
}, " 设置扩展属性 "),
vue.createElementVNode("button", {
class: "button button2",
onClick: _cache[36] || (_cache[36] = ($event) => vue.unref(modalOptions2).docommand("Mx_Test_DimAligned"))
}, " 绘制对齐标注 ")
]),
vue.createElementVNode("div", _hoisted_17, [
vue.createElementVNode("button", {
class: "button button2",
onClick: _cache[37] || (_cache[37] = ($event) => vue.unref(modalOptions2).docommand("Mx_Test_DrawDimRotated"))
}, " 绘性线标注 "),
vue.createElementVNode("button", {
class: "button button2",
onClick: _cache[38] || (_cache[38] = ($event) => vue.unref(modalOptions2).docommand("Mx_Test_DrawDimAngular"))
}, " 角度标注 "),
vue.createElementVNode("button", {
class: "button button2",
onClick: _cache[39] || (_cache[39] = ($event) => vue.unref(modalOptions2).docommand("MxTest_LineTypeTest"))
}, " 修改对象线型 "),
vue.createElementVNode("button", {
class: "button button2",
onClick: _cache[40] || (_cache[40] = ($event) => vue.unref(modalOptions2).docommand("Mx_SelectEntitHideLayer"))
}, " 选择隐藏对象层 ")
]),
vue.createElementVNode("div", _hoisted_18, [
vue.createElementVNode("button", {
class: "button button2",
onClick: _cache[41] || (_cache[41] = ($event) => vue.unref(modalOptions2).docommand("MxTest_TestAddCurrentSelect"))
}, " 添加到当前选择 "),
vue.createElementVNode("button", {
class: "button button2",
onClick: _cache[42] || (_cache[42] = ($event) => vue.unref(modalOptions2).docommand("MxTest_TestSetViewAngle"))
}, " 视区旋转 "),
vue.createElementVNode("button", {
class: "button button2",
onClick: _cache[43] || (_cache[43] = ($event) => vue.unref(modalOptions2).docommand("MxTest_WriteXRecord"))
}, " 写扩展记录 "),
vue.createElementVNode("button", {
class: "button button2",
onClick: _cache[44] || (_cache[44] = ($event) => vue.unref(modalOptions2).docommand("MxTest_GetNamedObjectsDictionary"))
}, " 得到命名字典 ")
]),
vue.createElementVNode("div", _hoisted_19, [
vue.createElementVNode("button", {
class: "button button2",
onClick: _cache[45] || (_cache[45] = ($event) => vue.unref(modalOptions2).docommand("MxTest_AddTextStyleTable"))
}, " 添加文字样式 "),
vue.createElementVNode("button", {
class: "button button2",
onClick: _cache[46] || (_cache[46] = ($event) => vue.unref(modalOptions2).docommand("MxTest_DrawCustomEntity"))
}, " 绘自定义实体 "),
vue.createElementVNode("button", {
class: "button button2",
onClick: _cache[47] || (_cache[47] = ($event) => vue.unref(modalOptions2).docommand("Mx_Test_ChangeColor"))
}, " 修改对象颜色 "),
vue.createElementVNode("button", {
class: "button button2",
onClick: _cache[48] || (_cache[48] = ($event) => vue.unref(modalOptions2).docommand("Mx_Test_ChangeVisible"))
}, " 修改对象不可见 ")
]),
vue.createElementVNode("div", _hoisted_20, [
vue.createElementVNode("button", {
class: "button button2",
onClick: _cache[49] || (_cache[49] = ($event) => vue.unref(modalOptions2).docommand("Mx_Test_ChangeEntityLayer"))
}, " 修改对象层 "),
vue.createElementVNode("button", {
class: "button button2",
onClick: _cache[50] || (_cache[50] = ($event) => vue.unref(modalOptions2).docommand("Mx_ChaneEntityDrawOrder"))
}, " 修改对象显示顺序 "),
vue.createElementVNode("button", {
class: "button button2",
onClick: _cache[51] || (_cache[51] = ($event) => vue.unref(modalOptions2).docommand("Mx_Export_Pdf"))
}, " 指定范围输出pdf "),
vue.createElementVNode("button", {
class: "button button2",
onClick: _cache[52] || (_cache[52] = ($event) => vue.unref(modalOptions2).docommand("Mx_Test_DrawImage"))
}, " 绘制image ")
]),
vue.createElementVNode("div", _hoisted_21, [
vue.createElementVNode("button", {
class: "button button2",
onClick: _cache[53] || (_cache[53] = ($event) => vue.unref(modalOptions2).docommand("MxTest_GetObjectExDictionaryData"))
}, " 读取对象扩展字典 ")
])
])
])
])) : vue.createCommentVNode("", true)
]);
};
}
});
const Modal_vue_vue_type_style_index_0_scoped_9bd7093d_lang = "";
const _export_sfc = (sfc, props) => {
const target = sfc.__vccOpts || sfc;
for (const [key, val] of props) {
target[key] = val;
}
return target;
};
const Modal = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-9bd7093d"]]);
const _sfc_main = /* @__PURE__ */ vue.defineComponent({
__name: "Test",
setup(__props) {
return (_ctx, _cache) => {
return vue.openBlock(), vue.createElementBlock("div", null, [
vue.createVNode(Modal)
]);
};
}
});
const MxIFrame = {
init() {
mxdraw.MxFun.setPostMessageToParentFrameFunction(function(param) {
top.postMessage(param, "*");
});
window.addEventListener("message", function(event) {
if (event.data.type === "sendStringToExecute") {
mxdraw.MxFun.sendStringToExecute(event.data.cmd, event.data);
} else {
console.log("mx:unprocessed message:");
console.log(event.data);
}
}, false);
}
};
function init$p() {
MxIFrame.init();
}
function BR_Comment() {
return __async(this, null, function* () {
const getPoint = new mxdraw.MrxDbgUiPrPoint();
getPoint.setMessage("\n指定第一点:");
getPoint.go((status) => {
if (status != 0) {
return;
}
const pt1 = getPoint.value();
let leadComment = new mxdraw.MxDbLeadComment();
leadComment.point1 = pt1.clone();
leadComment.textHeight = mxdraw.MxFun.screenCoordLong2Doc(50);
leadComment.text = "测试Test1";
leadComment.textWidth = mxdraw.MxFun.screenCoordLong2Doc(300);
leadComment.fixedSize = true;
if (leadComment.fixedSize) {
leadComment.textHeight = 50;
leadComment.textWidth = 250;
}
leadComment.color = mxcad2.MxCpp.getCurrentMxCAD().getCurrentDatabaseDrawColor();
const worldDrawComment = new mxdraw.McEdGetPointWorldDrawObject();
worldDrawComment.setDraw(
(currentPoint, pWorldDraw) => {
leadComment.point2 = currentPoint;
pWorldDraw.drawCustomEntity(leadComment);
}
);
getPoint.setBasePt(pt1);
getPoint.setUseBasePt(true);
getPoint.setUserDraw(worldDrawComment);
getPoint.setMessage("\n指定第二点:");
getPoint.go((status2) => {
if (status2 != 0) {
console.log(status2);
return;
}
const currentPoint = getPoint.value();
leadComment.point2 = currentPoint;
mxdraw.MxFun.addToCurrentSpace(leadComment);
});
});
});
}
function BR_Print() {
mxdraw.MxFun.getCurrentDraw().createCanvasImageData(
(imageData) => {
const newWindow = window.open();
if (newWindow != null) {
newWindow.document.write('
');
setTimeout(() => {
newWindow.print();
}, 300);
}
},
{
width: 349,
height: 536
}
);
}
function BR_CheckDraw() {
return __async(this, null, function* () {
let color = mxcad2.MxCpp.getCurrentMxCAD().getCurrentDatabaseDrawColor();
const point = new mxdraw.MrxDbgUiPrPoint();
const mxDraw = mxdraw.MxFun.getCurrentDraw();
const worldDrawComment = new mxdraw.McEdGetPointWorldDrawObject();
const mxCheckDraw = new mxdraw.MxDbRectBoxLeadComment();
mxCheckDraw.color = color.getHex();
if (mxCheckDraw.color == 0)
mxCheckDraw.color = 65793;
mxCheckDraw.radius = mxdraw.MxFun.screenCoordLong2Doc(8);
mxCheckDraw.setLineWidth(3);
mxCheckDraw.setLineWidthByPixels(true);
point.setMessage("\n云线框起始点:");
point.go((status) => {
if (status != mxdraw.MrxDbgUiPrBaseReturn.kOk) {
return;
}
mxCheckDraw.point1 = point.value();
worldDrawComment.setDraw((currentPoint) => {
mxCheckDraw.point2 = currentPoint;
worldDrawComment.drawCustomEntity(mxCheckDraw);
});
point.setUserDraw(worldDrawComment);
point.setMessage("\n云线框结束点:");
point.go((status2) => {
if (status2 != mxdraw.MrxDbgUiPrBaseReturn.kOk) {
return;
}
mxCheckDraw.point2 = point.value();
worldDrawComment.setDraw((currentPoint) => {
mxCheckDraw.point3 = currentPoint;
worldDrawComment.drawCustomEntity(mxCheckDraw);
});
mxCheckDraw.text = "审图批注XXXXXXXXXX";
mxCheckDraw.textWidth = mxdraw.MxFun.screenCoordLong2Doc(200);
mxCheckDraw.textHeight = mxdraw.MxFun.screenCoordLong2Doc(50);
mxCheckDraw.fixedSize = true;
if (mxCheckDraw.fixedSize) {
mxCheckDraw.textHeight = 20;
mxCheckDraw.textWidth = 230;
}
point.setMessage("\n审图标注点:");
point.go((status3) => {
if (status3 != mxdraw.MrxDbgUiPrBaseReturn.kOk) {
return;
}
mxCheckDraw.point3 = point.value();
mxDraw.addMxEntity(mxCheckDraw);
});
});
});
});
}
function getScreenPixel(pixel, isFontSize) {
let _pixel = mxdraw.MxFun.screenCoordLong2World(isFontSize ? pixel : pixel - pixel / 3);
_pixel = mxdraw.MxFun.worldCoordLong2Doc(_pixel);
return _pixel;
}
function BR_Arrow() {
const worldDraw = new mxdraw.McEdGetPointWorldDrawObject();
const lines = new mxdraw.MxDbArrow();
const mxDraw = mxdraw.MxFun.getCurrentDraw();
const point = new mxdraw.MrxDbgUiPrPoint();
point.setUserDraw(worldDraw);
lines.setLineWidth(10);
lines.innerOffset = getScreenPixel(10);
lines.outerOffset = getScreenPixel(22);
lines.topOffset = getScreenPixel(36);
lines.color = mxcad2.MxCpp.getCurrentMxCAD().getCurrentDatabaseDrawColor();
point.go(() => {
lines.startPoint = point.value();
worldDraw.setDraw((v) => {
lines.endPoint = v;
worldDraw.drawCustomEntity(lines);
});
point.go((status) => __async(this, null, function* () {
lines.endPoint = point.value();
mxDraw.addMxEntity(lines);
}));
});
}
function BR_CloudLine() {
const point = new mxdraw.MrxDbgUiPrPoint();
const mxDraw = mxdraw.MxFun.getCurrentDraw();
const worldDrawComment = new mxdraw.McEdGetPointWorldDrawObject();
const radius = mxdraw.MxFun.screenCoordLong2Doc(16);
point.setMessage("\n点击开启绘制云线:");
point.go(() => {
let pt = point.value();
const mxCloudLine = new mxdraw.MxDbCloudLine();
mxCloudLine.setRadius(radius);
mxCloudLine.addPoint(pt);
mxCloudLine.color = mxcad2.MxCpp.getCurrentMxCAD().getCurrentDatabaseDrawColor();
worldDrawComment.setDraw((currentPoint) => {
if (pt.distanceTo(currentPoint) > radius) {
pt = currentPoint.clone();
mxCloudLine.addPoint(currentPoint, true);
}
worldDrawComment.drawCustomEntity(mxCloudLine);
});
point.setUserDraw(worldDrawComment);
point.setMessage("\n再次点击结束绘制云线:");
point.go(() => {
mxDraw.addMxEntity(mxCloudLine);
});
});
}
let sSaveData = "";
function BR_SaveAllMxEntity() {
let mxobj = mxdraw.MxFun.getCurrentDraw();
sSaveData = mxobj.saveMxEntityToJson();
console.log(sSaveData);
}
function BR_LoadAllMxEntity() {
return __async(this, null, function* () {
if (sSaveData.length == 0)
return;
let mxobj = mxdraw.MxFun.getCurrentDraw();
yield mxobj.loadMxEntityFromJson(sSaveData, ["models/svg/mark.svg"]);
mxobj.updateDisplay();
});
}
function BR_Area() {
const getPoint = new mxdraw.MrxDbgUiPrPoint();
getPoint.setMessage("\n指定第一点:");
getPoint.go((status) => {
if (status != 0) {
return;
}
const pt1 = getPoint.value();
let area2 = new mxdraw.MxDbArea();
area2.addPoint(pt1);
area2.color = mxcad2.MxCpp.getCurrentMxCAD().getCurrentDatabaseDrawColor();
const worldDrawComment = new mxdraw.McEdGetPointWorldDrawObject();
worldDrawComment.setDraw((currentPoint, pWorldDraw) => {
let tmp2 = area2.clone();
tmp2.addPoint(currentPoint);
worldDrawComment.drawCustomEntity(tmp2);
});
getPoint.setUserDraw(worldDrawComment);
getPoint.setMessage("\n指定下一点:");
getPoint.goWhile(
(status2) => {
if (status2 == 0) {
const pt2 = getPoint.value();
area2.addPoint(pt2);
}
},
(status2) => {
area2.isFill = true;
area2.fillOpacity = 0.7;
area2.fillColor = 6697540;
mxdraw.MxFun.getCurrentDraw().addMxEntity(area2);
}
);
});
}
function init$o() {
mxdraw.MxFun.addCommand("BR_Comment", BR_Comment);
mxdraw.MxFun.addCommand("BR_CheckDraw", BR_CheckDraw);
mxdraw.MxFun.addCommand("BR_Arrow", BR_Arrow);
mxdraw.MxFun.addCommand("BR_CloudLine", BR_CloudLine);
mxdraw.MxFun.addCommand("BR_Print", BR_Print);
mxdraw.MxFun.addCommand("BR_SaveAllMxEntity", BR_SaveAllMxEntity);
mxdraw.MxFun.addCommand("BR_LoadAllMxEntity", BR_LoadAllMxEntity);
mxdraw.MxFun.addCommand("BR_Area", BR_Area);
}
function Mx_Test_DrawLine() {
let mxcad$1 = mxcad2.MxCpp.getCurrentMxCAD();
mxcad$1.newFile();
mxcad$1.drawColorIndex = 0;
mxcad$1.drawLinetype = "";
mxcad$1.drawLineWidth = 0;
mxcad$1.addLayer("LineLayer");
mxcad$1.drawLayer = "LineLayer";
mxcad$1.drawLine(0, 0, 100, 0);
mxcad$1.drawLine(200, 0, 300, 100);
mxcad$1.addLinetype("MyLineType", "6,-10");
mxcad$1.drawLinetype = "MyLineType";
mxcad$1.drawLine(0, 30, 100, 30);
mxcad$1.drawLine(200, 30, 300, 130);
mxcad$1.drawColor = new mxcad2.McCmColor(0, 0, 255);
mxcad$1.drawLine(0, 60, 100, 60);
mxcad$1.drawLine(200, 60, 300, 160);
mxcad$1.drawColorIndex = 0;
mxcad$1.drawLinetype = "";
mxcad$1.drawLineWidth = 4;
mxcad$1.drawLine(0, 90, 100, 90);
mxcad$1.drawLine(200, 90, 300, 190);
mxcad$1.addLinetype("MyLineType2", "10,-2,3,-2");
mxcad$1.drawLinetype = "MyLineType2";
mxcad$1.drawColor = new mxcad2.McCmColor(255, 0, 0);
mxcad$1.drawLine(0, 120, 100, 120);
mxcad$1.drawLine(200, 120, 300, 220);
mxcad$1.addTextStyle("MyLineTypeTextStyle", "txt.shx", "hztxt.shx", 1);
mxcad$1.addLinetypeEx("MyLineType3", '(12.7,("T=MxDraw","S=2.54","L=-5.08","R=0.0","X=-2.54","Y=-1.27"),-10.08)', "MyLineTypeTextStyle");
mxcad$1.drawLinetype = "MyLineType3";
mxcad$1.drawLineWidth = 0;
mxcad$1.drawLine(350, 120, 600, 120);
mxcad$1.drawColorIndex = 0;
mxcad$1.drawLineWidth = 4;
mxcad$1.drawLine(350, 220, 600, 220);
mxcad$1.zoomAll();
mxcad$1.updateDisplay();
}
function Mx_Test_DrawArc() {
let mxcad$1 = mxcad2.MxCpp.getCurrentMxCAD();
mxcad$1.newFile();
mxcad$1.drawColorIndex = 0;
mxcad$1.drawLinetype = "";
mxcad$1.drawLineWidth = 0;
mxcad$1.addLayer("ArcLayer");
mxcad$1.drawLayer = "ArcLayer";
mxcad$1.drawArc(0, 1e3, 100, 30, 200);
mxcad$1.addLinetype("ArcLineType", "30,-5,7,-7");
mxcad$1.drawLinetype = "ArcLineType";
mxcad$1.drawColor = new mxcad2.McCmColor(255, 25, 0);
mxcad$1.drawArc(300, 1e3, 100, 30, 200);
mxcad$1.drawLineWidth = 15;
mxcad$1.drawColorIndex = 255;
mxcad$1.drawArc(600, 1e3, 100, 30, 200);
mxcad$1.drawArc2(800, 1e3, 900, 1200, 1e3, 900);
mxcad$1.drawLinetype = "";
mxcad$1.drawLineWidth = 40;
mxcad$1.drawArc3(1200, 1e3, 1400, 1e3, 0.6);
mxcad$1.zoomAll();
mxcad$1.regen();
mxcad$1.updateDisplay();
}
function Mx_Test_DrawCircle() {
let mxcad$1 = mxcad2.MxCpp.getCurrentMxCAD();
mxcad$1.newFile();
mxcad$1.drawColorIndex = 0;
mxcad$1.drawLinetype = "";
mxcad$1.drawLineWidth = 0;
mxcad$1.addLayer("CircleLayer");
mxcad$1.drawLayer = "CircleLayer";
mxcad$1.drawCircle(0, 800, 120);
mxcad$1.addLinetype("CircleLineType", "30,-5,7,-7");
mxcad$1.drawLinetype = "CircleLineType";
mxcad$1.drawColor = new mxcad2.McCmColor(0, 25, 255);
mxcad$1.drawCircle(300, 800, 120);
mxcad$1.addLinetype("CircleLineType", "30,-5,7,-7");
mxcad$1.drawLinetype = "CircleLineType";
mxcad$1.drawLineWidth = 40;
mxcad$1.drawCircle(600, 800, 120);
mxcad$1.zoomAll();
mxcad$1.regen();
mxcad$1.updateDisplay();
}
function Mx_Test_DrawPolyline() {
let mxcad$1 = mxcad2.MxCpp.getCurrentMxCAD();
mxcad$1.newFile();
mxcad$1.drawColorIndex = 0;
mxcad$1.drawLinetype = "";
mxcad$1.drawLineWidth = 0;
mxcad$1.addLayer("PolylineLayer");
mxcad$1.drawLayer = "PolylineLayer";
mxcad$1.pathMoveTo(0, 300);
mxcad$1.pathLineTo(100, 300);
mxcad$1.pathLineTo(100, 400);
mxcad$1.pathLineTo(0, 400);
mxcad$1.pathMakeClosed();
mxcad$1.drawPathToPolyline();
mxcad$1.pathMoveTo(200, 300);
mxcad$1.pathLineTo(300, 300);
mxcad$1.pathLineTo(300, 400);
mxcad$1.pathLineTo(200, 400);
mxcad$1.pathMakeClosed();
mxcad$1.addLinetype("MyLineType3", "30,-10");
mxcad$1.drawLinetype = "MyLineType3";
mxcad$1.drawColorIndex = 255;
mxcad$1.drawLineWidth = 5;
mxcad$1.drawPathToPolyline();
mxcad$1.pathMoveTo(400, 300);
mxcad$1.pathLineTo(500, 300);
mxcad$1.pathLineTo(500, 400);
mxcad$1.pathLineTo(400, 400);
mxcad$1.pathMakeClosed();
mxcad$1.drawLinetype = "";
mxcad$1.drawColor = new mxcad2.McCmColor(0, 25, 255);
mxcad$1.drawLineWidth = 10;
mxcad$1.drawPathToPolyline();
mxcad$1.pathMoveTo(400, 300);
mxcad$1.pathLineTo(500, 300);
mxcad$1.pathLineTo(500, 400);
mxcad$1.pathLineTo(400, 400);
mxcad$1.pathMakeClosed();
mxcad$1.drawLinetype = "";
mxcad$1.drawColor = new mxcad2.McCmColor(255, 25, 0);
mxcad$1.drawLineWidth = 10;
mxcad$1.drawPathToPolyline();
mxcad$1.pathMoveTo(600, 300);
mxcad$1.pathLineTo(700, 300);
mxcad$1.pathLineTo(700, 400);
mxcad$1.pathLineTo(600, 400);
mxcad$1.drawLinetype = "";
mxcad$1.drawColor = new mxcad2.McCmColor(0, 255, 0);
mxcad$1.drawLineWidth = 10;
mxcad$1.drawPathToPolyline();
mxcad$1.pathMoveTo(800, 300);
mxcad$1.pathLineTo(900, 300);
mxcad$1.pathLineTo(900, 400);
mxcad$1.pathMakeClosed();
mxcad$1.drawLinetype = "";
mxcad$1.drawColor = new mxcad2.McCmColor(25, 255, 0);
mxcad$1.drawLineWidth = 10;
mxcad$1.drawPathToPolyline();
mxcad$1.pathMoveToEx(1e3, 300, 10, 10, 0);
mxcad$1.pathLineToEx(1e3, 500, 30, 0, 0);
mxcad$1.pathLineTo(1e3, 580);
mxcad$1.drawPathToPolyline();
mxcad$1.pathMoveToEx(1200, 300, 10, 10, 0);
mxcad$1.pathLineToEx(1200, 500, 30, 0, 0);
mxcad$1.pathLineTo(1200, 580);
mxcad$1.drawColor = new mxcad2.McCmColor(25, 255, 0);
mxcad$1.drawLinetype = "MyLineType3";
mxcad$1.drawPathToPolyline();
mxcad$1.pathMoveToEx(1400, 300, 10, 10, -0.34);
mxcad$1.pathLineToEx(1400, 500, 30, 0, 0.34);
mxcad$1.pathLineTo(1400, 600);
mxcad$1.drawColor = new mxcad2.McCmColor(255, 255, 25);
mxcad$1.drawLinetype = "MyLineType3";
mxcad$1.drawPathToPolyline();
mxcad$1.zoomAll();
mxcad$1.regen();
mxcad$1.updateDisplay();
}
function Mx_Test_DrawHatch() {
let mxcad$1 = mxcad2.MxCpp.getCurrentMxCAD();
mxcad$1.newFile();
mxcad$1.drawColorIndex = 0;
mxcad$1.drawLinetype = "";
mxcad$1.drawLineWidth = 0;
mxcad$1.addLayer("HatchLayer");
mxcad$1.drawLayer = "HatchLayer";
mxcad$1.pathMoveToEx(200, 3300, 0, 0, 0.3);
mxcad$1.pathLineTo(300, 3300);
mxcad$1.pathLineTo(300, 3400);
mxcad$1.pathLineTo(200, 3300);
mxcad$1.drawColor = new mxcad2.McCmColor(25, 255, 0);
mxcad$1.drawPathToHatch(1);
mxcad$1.pathMoveTo(150, 3300);
mxcad$1.pathLineTo(250, 3300);
mxcad$1.pathLineTo(250, 3400);
mxcad$1.pathLineTo(150, 3300);
mxcad$1.drawColor = new mxcad2.McCmColor(255, 0, 0);
mxcad$1.drawPathToHatch(1);
mxcad$1.pathMoveToEx(440, 3310, 0, 0, 0);
mxcad$1.pathLineTo(480, 3310);
mxcad$1.pathLineTo(480, 3360);
mxcad$1.pathLineTo(450, 3340);
mxcad$1.pathMakeExclude(true);
mxcad$1.pathMoveToEx(400, 3300, 0, 0, 0.3);
mxcad$1.pathLineTo(500, 3300);
mxcad$1.pathLineTo(500, 3400);
mxcad$1.pathLineTo(400, 3300);
mxcad$1.drawColor = new mxcad2.McCmColor(255, 25, 0);
mxcad$1.drawPathToHatch(1);
mxcad$1.addPatternDefinition("MyHatchPattern1", "((45, 0,0, 0,0.125))");
mxcad$1.drawPatternDefinition = "MyHatchPattern1";
mxcad$1.pathMoveToEx(600, 3300, 0, 0, 0.3);
mxcad$1.pathLineTo(700, 3300);
mxcad$1.pathLineTo(700, 3400);
mxcad$1.pathLineTo(600, 3300);
mxcad$1.drawPathToHatch(100);
mxcad$1.addPatternDefinition("MyHatchPattern2", "((45, 0,0, 0,0.25) (45, 0.176776695,0, 0,0.25, 0.125,-0.0625))");
mxcad$1.drawPatternDefinition = "MyHatchPattern2";
mxcad$1.pathMoveToEx(800, 3300, 0, 0, 0.3);
mxcad$1.pathLineTo(900, 3300);
mxcad$1.pathLineTo(900, 3400);
mxcad$1.pathLineTo(800, 3300);
mxcad$1.drawPathToHatch(100);
mxcad$1.zoomAll();
mxcad$1.regen();
mxcad$1.updateDisplay();
}
function Mx_Test_DrawText() {
let mxcad$1 = mxcad2.MxCpp.getCurrentMxCAD();
mxcad$1.newFile();
mxcad$1.drawColorIndex = 0;
mxcad$1.addLayer("TextLayer");
mxcad$1.drawLayer = "TextLayer";
mxcad$1.drawText(0, 1900, "绘图控件文字测试", 100, 0, 0, 1);
mxcad$1.drawColor = new mxcad2.McCmColor(255, 25, 0);
mxcad$1.drawText(3e3, 2100, "绘图控件文字测试", 100, -20, 2, 1);
mxcad$1.addTextStyle("MyTextStyle", "italicc.shx", "gbcbig.shx", 0.7);
mxcad$1.drawTextStyle = "MyTextStyle";
mxcad$1.drawColor = new mxcad2.McCmColor(255, 0, 0);
mxcad$1.drawText(0, 3e3, "绘图控件文字测试", 100, 0, 0, 1);
mxcad$1.AddTureTypeTextStyle("MyTrueTypeTextStyle");
mxcad$1.drawTextStyle = "MyTrueTypeTextStyle";
mxcad$1.drawColor = new mxcad2.McCmColor(200, 255, 50);
mxcad$1.drawText(0, 3500, "绘图控件TrueType文字测试", 100, 0, 0, 1);
mxcad$1.zoomAll();
mxcad$1.regen();
mxcad$1.updateDisplay();
}
function Mx_Test_Ellipse() {
let mxcad$1 = mxcad2.MxCpp.getCurrentMxCAD();
mxcad$1.newFile();
mxcad$1.drawColorIndex = 0;
mxcad$1.drawLinetype = "";
mxcad$1.drawLineWidth = 0;
mxcad$1.addLayer("LineLayer");
mxcad$1.drawLayer = "LineLayer";
mxcad$1.drawEllipse(0, 1400, 100, 0, 0.7);
mxcad$1.addLinetype("MyEllipseType", "6,-10");
mxcad$1.drawLinetype = "MyEllipseType";
mxcad$1.drawColor = new mxcad2.McCmColor(200, 0, 0);
mxcad$1.drawEllipse(200, 1400, 80, 30, 0.5);
mxcad$1.zoomAll();
mxcad$1.regen();
mxcad$1.updateDisplay();
}
function Mx_Test_EllipseArc() {
let mxcad$1 = mxcad2.MxCpp.getCurrentMxCAD();
mxcad$1.newFile();
mxcad$1.drawColorIndex = 0;
mxcad$1.drawLineWidth = 0;
mxcad$1.addLayer("EllipseArcLayer");
mxcad$1.drawLayer = "EllipseArcLayer";
mxcad$1.drawEllipseArc(0, 1600, 80, 30, 0.4, 30, 200);
mxcad$1.addLinetype("MyEllipseArcType", "6,-10");
mxcad$1.drawLinetype = "MyEllipseArcType";
mxcad$1.drawColor = new mxcad2.McCmColor(200, 200, 0);
mxcad$1.drawEllipseArc(200, 1600, -80, 30, 0.5, 60, 300);
mxcad$1.drawLinetype = "";
mxcad$1.zoomAll();
mxcad$1.regen();
mxcad$1.updateDisplay();
}
function Mx_Test_MText() {
let mxcad$1 = mxcad2.MxCpp.getCurrentMxCAD();
mxcad$1.newFile();
mxcad$1.drawColorIndex = 0;
mxcad$1.addLayer("MtextLayer");
mxcad$1.drawLayer = "MtextLayer";
mxcad$1.drawTextStyle = "";
mxcad$1.drawMText(0, -100, "控件:\\P多行文字测试", 50, 400, 0, 1);
mxcad$1.zoomAll();
mxcad$1.regen();
mxcad$1.updateDisplay();
}
function Mx_ParamDrawLine(data) {
if (!data || !data.param)
return;
let mxcad$1 = mxcad2.MxCpp.getCurrentMxCAD();
mxcad$1.newFile();
mxcad$1.drawColorIndex = 0;
mxcad$1.drawLinetype = "";
mxcad$1.drawLineWidth = 0;
mxcad$1.addLayer("LineLayer");
mxcad$1.drawLayer = "LineLayer";
mxcad$1.drawLine(data.param.x1, data.param.y1, data.param.x2, data.param.y2);
mxcad$1.zoomAll();
mxcad$1.updateDisplay();
mxdraw.MxFun.postMessageToParentFrame({ cmd: "Mx_ParamDrawLine", message: "ok" });
}
function Mx_Test_Text() {
let mxcad$1 = mxcad2.MxCpp.getCurrentMxCAD();
mxcad$1.newFile();
mxcad$1.drawText(
350831.77,
1940511845e-2,
"1.034",
10,
0,
mxcad2.McDb.TextHorzMode.kTextLeft,
mxcad2.McDb.TextVertMode.kTextVertMid
);
mxcad$1.zoomAll();
mxcad$1.regen(100);
}
function Mx_Test_DimAligned() {
let mxcad$1 = mxcad2.MxCpp.getCurrentMxCAD();
mxcad$1.newFile();
mxcad$1.addDimStyle("MyDimStyle", "41,0.18,141,0.09,40,200", "77,1,271,3", "", "");
mxcad$1.drawDimStyle = "MyDimStyle";
mxcad$1.drawColorIndex = 0;
mxcad$1.drawLinetype = "";
mxcad$1.drawLineWidth = 0;
mxcad$1.drawDimAligned(0, 4e3, 300, 4500, 150, 4600);
mxcad$1.zoomAll();
mxcad$1.updateDisplay();
}
function Mx_Test_DrawDimRotated() {
let mxcad$1 = mxcad2.MxCpp.getCurrentMxCAD();
mxcad$1.newFile();
mxcad$1.addDimStyle("MyDimStyle", "41,0.18,141,0.09,40,200", "77,1,271,3", "", "");
mxcad$1.drawDimStyle = "MyDimStyle";
mxcad$1.drawColorIndex = 0;
mxcad$1.drawLinetype = "";
mxcad$1.drawLineWidth = 0;
mxcad$1.drawDimRotated(0, 7e3, 600, 7e3, 250, 7050, 0);
mxcad$1.drawDimRotated(0, 7200, 0, 7600, 150, 7300, 0.771);
mxcad$1.zoomAll();
mxcad$1.updateDisplay();
}
function Mx_Test_DrawDimAngular() {
let mxcad$1 = mxcad2.MxCpp.getCurrentMxCAD();
mxcad$1.newFile();
mxcad$1.addDimStyle("MyDimStyle2", "41,0.18,141,0.09,40,200", "77,1,271,3", "", "");
mxcad$1.drawDimStyle = "MyDimStyle2";
mxcad$1.drawColorIndex = 0;
mxcad$1.drawLinetype = "";
mxcad$1.drawLineWidth = 0;
mxcad$1.drawDimAngular(500, 5e3, 0, 5500, 1e3, 5500, 500, 5500);
mxcad$1.zoomAll();
mxcad$1.updateDisplay();
}
function init$n() {
mxdraw.MxFun.addCommand("Mx_Test_DrawLine", Mx_Test_DrawLine);
mxdraw.MxFun.addCommand("Mx_Test_DrawArc", Mx_Test_DrawArc);
mxdraw.MxFun.addCommand("Mx_Test_DrawCircle", Mx_Test_DrawCircle);
mxdraw.MxFun.addCommand("Mx_Test_DrawPolyline", Mx_Test_DrawPolyline);
mxdraw.MxFun.addCommand("Mx_Test_DrawHatch", Mx_Test_DrawHatch);
mxdraw.MxFun.addCommand("Mx_Test_DrawText", Mx_Test_DrawText);
mxdraw.MxFun.addCommand("Mx_Test_Ellipse", Mx_Test_Ellipse);
mxdraw.MxFun.addCommand("Mx_Test_EllipseArc", Mx_Test_EllipseArc);
mxdraw.MxFun.addCommand("Mx_Test_MText", Mx_Test_MText);
mxdraw.MxFun.addCommand("Mx_Test_Text", Mx_Test_Text);
mxdraw.MxFun.addCommand("Mx_ParamDrawLine", Mx_ParamDrawLine);
mxdraw.MxFun.addCommand("Mx_Test_DimAligned", Mx_Test_DimAligned);
mxdraw.MxFun.addCommand("Mx_Test_DrawDimRotated", Mx_Test_DrawDimRotated);
mxdraw.MxFun.addCommand("Mx_Test_DrawDimAngular", Mx_Test_DrawDimAngular);
}
if (Number.EPSILON === void 0) {
Number.EPSILON = Math.pow(2, -52);
}
if (Number.isInteger === void 0) {
Number.isInteger = function(value) {
return typeof value === "number" && isFinite(value) && Math.floor(value) === value;
};
}
if (Math.sign === void 0) {
Math.sign = function(x) {
return x < 0 ? -1 : x > 0 ? 1 : +x;
};
}
if ("name" in Function.prototype === false) {
Object.defineProperty(Function.prototype, "name", {
get: function() {
return this.toString().match(/^\s*function\s*([^\(\s]*)/)[1];
}
});
}
if (Object.assign === void 0) {
Object.assign = function(target) {
if (target === void 0 || target === null) {
throw new TypeError("Cannot convert undefined or null to object");
}
var output = Object(target);
for (var index = 1; index < arguments.length; index++) {
var source = arguments[index];
if (source !== void 0 && source !== null) {
for (var nextKey in source) {
if (Object.prototype.hasOwnProperty.call(source, nextKey)) {
output[nextKey] = source[nextKey];
}
}
}
}
return output;
};
}
var REVISION = "113";
var CullFaceNone = 0;
var CullFaceBack = 1;
var CullFaceFront = 2;
var PCFShadowMap = 1;
var PCFSoftShadowMap = 2;
var VSMShadowMap = 3;
var FrontSide = 0;
var BackSide = 1;
var DoubleSide = 2;
var FlatShading = 1;
var NoColors = 0;
var FaceColors = 1;
var VertexColors = 2;
var NoBlending = 0;
var NormalBlending = 1;
var AdditiveBlending = 2;
var SubtractiveBlending = 3;
var MultiplyBlending = 4;
var CustomBlending = 5;
var AddEquation = 100;
var SubtractEquation = 101;
var ReverseSubtractEquation = 102;
var MinEquation = 103;
var MaxEquation = 104;
var ZeroFactor = 200;
var OneFactor = 201;
var SrcColorFactor = 202;
var OneMinusSrcColorFactor = 203;
var SrcAlphaFactor = 204;
var OneMinusSrcAlphaFactor = 205;
var DstAlphaFactor = 206;
var OneMinusDstAlphaFactor = 207;
var DstColorFactor = 208;
var OneMinusDstColorFactor = 209;
var SrcAlphaSaturateFactor = 210;
var NeverDepth = 0;
var AlwaysDepth = 1;
var LessDepth = 2;
var LessEqualDepth = 3;
var EqualDepth = 4;
var GreaterEqualDepth = 5;
var GreaterDepth = 6;
var NotEqualDepth = 7;
var MultiplyOperation = 0;
var MixOperation = 1;
var AddOperation = 2;
var NoToneMapping = 0;
var LinearToneMapping = 1;
var ReinhardToneMapping = 2;
var Uncharted2ToneMapping = 3;
var CineonToneMapping = 4;
var ACESFilmicToneMapping = 5;
var UVMapping = 300;
var CubeReflectionMapping = 301;
var CubeRefractionMapping = 302;
var EquirectangularReflectionMapping = 303;
var EquirectangularRefractionMapping = 304;
var SphericalReflectionMapping = 305;
var CubeUVReflectionMapping = 306;
var CubeUVRefractionMapping = 307;
var RepeatWrapping = 1e3;
var ClampToEdgeWrapping = 1001;
var MirroredRepeatWrapping = 1002;
var NearestFilter = 1003;
var NearestMipmapNearestFilter = 1004;
var NearestMipmapLinearFilter = 1005;
var LinearFilter = 1006;
var LinearMipmapNearestFilter = 1007;
var LinearMipmapLinearFilter = 1008;
var UnsignedByteType = 1009;
var ByteType = 1010;
var ShortType = 1011;
var UnsignedShortType = 1012;
var IntType = 1013;
var UnsignedIntType = 1014;
var FloatType = 1015;
var HalfFloatType = 1016;
var UnsignedShort4444Type = 1017;
var UnsignedShort5551Type = 1018;
var UnsignedShort565Type = 1019;
var UnsignedInt248Type = 1020;
var AlphaFormat = 1021;
var RGBFormat = 1022;
var RGBAFormat = 1023;
var LuminanceFormat = 1024;
var LuminanceAlphaFormat = 1025;
var RGBEFormat = RGBAFormat;
var DepthFormat = 1026;
var DepthStencilFormat = 1027;
var RedFormat = 1028;
var RedIntegerFormat = 1029;
var RGFormat = 1030;
var RGIntegerFormat = 1031;
var RGBIntegerFormat = 1032;
var RGBAIntegerFormat = 1033;
var RGB_S3TC_DXT1_Format = 33776;
var RGBA_S3TC_DXT1_Format = 33777;
var RGBA_S3TC_DXT3_Format = 33778;
var RGBA_S3TC_DXT5_Format = 33779;
var RGB_PVRTC_4BPPV1_Format = 35840;
var RGB_PVRTC_2BPPV1_Format = 35841;
var RGBA_PVRTC_4BPPV1_Format = 35842;
var RGBA_PVRTC_2BPPV1_Format = 35843;
var RGB_ETC1_Format = 36196;
var RGBA_ASTC_4x4_Format = 37808;
var RGBA_ASTC_5x4_Format = 37809;
var RGBA_ASTC_5x5_Format = 37810;
var RGBA_ASTC_6x5_Format = 37811;
var RGBA_ASTC_6x6_Format = 37812;
var RGBA_ASTC_8x5_Format = 37813;
var RGBA_ASTC_8x6_Format = 37814;
var RGBA_ASTC_8x8_Format = 37815;
var RGBA_ASTC_10x5_Format = 37816;
var RGBA_ASTC_10x6_Format = 37817;
var RGBA_ASTC_10x8_Format = 37818;
var RGBA_ASTC_10x10_Format = 37819;
var RGBA_ASTC_12x10_Format = 37820;
var RGBA_ASTC_12x12_Format = 37821;
var LoopOnce = 2200;
var LoopRepeat = 2201;
var LoopPingPong = 2202;
var InterpolateDiscrete = 2300;
var InterpolateLinear = 2301;
var InterpolateSmooth = 2302;
var ZeroCurvatureEnding = 2400;
var ZeroSlopeEnding = 2401;
var WrapAroundEnding = 2402;
var TrianglesDrawMode = 0;
var TriangleStripDrawMode = 1;
var TriangleFanDrawMode = 2;
var LinearEncoding = 3e3;
var sRGBEncoding = 3001;
var GammaEncoding = 3007;
var RGBEEncoding = 3002;
var LogLuvEncoding = 3003;
var RGBM7Encoding = 3004;
var RGBM16Encoding = 3005;
var RGBDEncoding = 3006;
var BasicDepthPacking = 3200;
var RGBADepthPacking = 3201;
var TangentSpaceNormalMap = 0;
var ObjectSpaceNormalMap = 1;
var KeepStencilOp = 7680;
var AlwaysStencilFunc = 519;
var StaticDrawUsage = 35044;
var DynamicDrawUsage = 35048;
function EventDispatcher() {
}
Object.assign(EventDispatcher.prototype, {
addEventListener: function(type, listener) {
if (this._listeners === void 0)
this._listeners = {};
var listeners = this._listeners;
if (listeners[type] === void 0) {
listeners[type] = [];
}
if (listeners[type].indexOf(listener) === -1) {
listeners[type].push(listener);
}
},
hasEventListener: function(type, listener) {
if (this._listeners === void 0)
return false;
var listeners = this._listeners;
return listeners[type] !== void 0 && listeners[type].indexOf(listener) !== -1;
},
removeEventListener: function(type, listener) {
if (this._listeners === void 0)
return;
var listeners = this._listeners;
var listenerArray = listeners[type];
if (listenerArray !== void 0) {
var index = listenerArray.indexOf(listener);
if (index !== -1) {
listenerArray.splice(index, 1);
}
}
},
dispatchEvent: function(event) {
if (this._listeners === void 0)
return;
var listeners = this._listeners;
var listenerArray = listeners[event.type];
if (listenerArray !== void 0) {
event.target = this;
var array = listenerArray.slice(0);
for (var i2 = 0, l = array.length; i2 < l; i2++) {
array[i2].call(this, event);
}
}
}
});
var _lut = [];
for (var i = 0; i < 256; i++) {
_lut[i] = (i < 16 ? "0" : "") + i.toString(16);
}
var MathUtils = {
DEG2RAD: Math.PI / 180,
RAD2DEG: 180 / Math.PI,
generateUUID: function() {
var d0 = Math.random() * 4294967295 | 0;
var d1 = Math.random() * 4294967295 | 0;
var d2 = Math.random() * 4294967295 | 0;
var d3 = Math.random() * 4294967295 | 0;
var uuid = _lut[d0 & 255] + _lut[d0 >> 8 & 255] + _lut[d0 >> 16 & 255] + _lut[d0 >> 24 & 255] + "-" + _lut[d1 & 255] + _lut[d1 >> 8 & 255] + "-" + _lut[d1 >> 16 & 15 | 64] + _lut[d1 >> 24 & 255] + "-" + _lut[d2 & 63 | 128] + _lut[d2 >> 8 & 255] + "-" + _lut[d2 >> 16 & 255] + _lut[d2 >> 24 & 255] + _lut[d3 & 255] + _lut[d3 >> 8 & 255] + _lut[d3 >> 16 & 255] + _lut[d3 >> 24 & 255];
return uuid.toUpperCase();
},
clamp: function(value, min, max) {
return Math.max(min, Math.min(max, value));
},
// compute euclidian modulo of m % n
// https://en.wikipedia.org/wiki/Modulo_operation
euclideanModulo: function(n, m) {
return (n % m + m) % m;
},
// Linear mapping from range to range
mapLinear: function(x, a1, a2, b1, b2) {
return b1 + (x - a1) * (b2 - b1) / (a2 - a1);
},
// https://en.wikipedia.org/wiki/Linear_interpolation
lerp: function(x, y, t) {
return (1 - t) * x + t * y;
},
// http://en.wikipedia.org/wiki/Smoothstep
smoothstep: function(x, min, max) {
if (x <= min)
return 0;
if (x >= max)
return 1;
x = (x - min) / (max - min);
return x * x * (3 - 2 * x);
},
smootherstep: function(x, min, max) {
if (x <= min)
return 0;
if (x >= max)
return 1;
x = (x - min) / (max - min);
return x * x * x * (x * (x * 6 - 15) + 10);
},
// Random integer from interval
randInt: function(low, high) {
return low + Math.floor(Math.random() * (high - low + 1));
},
// Random float from interval
randFloat: function(low, high) {
return low + Math.random() * (high - low);
},
// Random float from <-range/2, range/2> interval
randFloatSpread: function(range) {
return range * (0.5 - Math.random());
},
degToRad: function(degrees) {
return degrees * MathUtils.DEG2RAD;
},
radToDeg: function(radians) {
return radians * MathUtils.RAD2DEG;
},
isPowerOfTwo: function(value) {
return (value & value - 1) === 0 && value !== 0;
},
ceilPowerOfTwo: function(value) {
return Math.pow(2, Math.ceil(Math.log(value) / Math.LN2));
},
floorPowerOfTwo: function(value) {
return Math.pow(2, Math.floor(Math.log(value) / Math.LN2));
},
setQuaternionFromProperEuler: function(q, a, b, c, order) {
var cos = Math.cos;
var sin = Math.sin;
var c2 = cos(b / 2);
var s2 = sin(b / 2);
var c13 = cos((a + c) / 2);
var s13 = sin((a + c) / 2);
var c1_3 = cos((a - c) / 2);
var s1_3 = sin((a - c) / 2);
var c3_1 = cos((c - a) / 2);
var s3_1 = sin((c - a) / 2);
if (order === "XYX") {
q.set(c2 * s13, s2 * c1_3, s2 * s1_3, c2 * c13);
} else if (order === "YZY") {
q.set(s2 * s1_3, c2 * s13, s2 * c1_3, c2 * c13);
} else if (order === "ZXZ") {
q.set(s2 * c1_3, s2 * s1_3, c2 * s13, c2 * c13);
} else if (order === "XZX") {
q.set(c2 * s13, s2 * s3_1, s2 * c3_1, c2 * c13);
} else if (order === "YXY") {
q.set(s2 * c3_1, c2 * s13, s2 * s3_1, c2 * c13);
} else if (order === "ZYZ") {
q.set(s2 * s3_1, s2 * c3_1, c2 * s13, c2 * c13);
} else {
console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order.");
}
}
};
function Vector2(x, y) {
this.x = x || 0;
this.y = y || 0;
}
Object.defineProperties(Vector2.prototype, {
"width": {
get: function() {
return this.x;
},
set: function(value) {
this.x = value;
}
},
"height": {
get: function() {
return this.y;
},
set: function(value) {
this.y = value;
}
}
});
Object.assign(Vector2.prototype, {
isVector2: true,
set: function(x, y) {
this.x = x;
this.y = y;
return this;
},
setScalar: function(scalar) {
this.x = scalar;
this.y = scalar;
return this;
},
setX: function(x) {
this.x = x;
return this;
},
setY: function(y) {
this.y = y;
return this;
},
setComponent: function(index, value) {
switch (index) {
case 0:
this.x = value;
break;
case 1:
this.y = value;
break;
default:
throw new Error("index is out of range: " + index);
}
return this;
},
getComponent: function(index) {
switch (index) {
case 0:
return this.x;
case 1:
return this.y;
default:
throw new Error("index is out of range: " + index);
}
},
clone: function() {
return new this.constructor(this.x, this.y);
},
copy: function(v) {
this.x = v.x;
this.y = v.y;
return this;
},
add: function(v, w) {
if (w !== void 0) {
console.warn("THREE.Vector2: .add() now only accepts one argument. Use .addVectors( a, b ) instead.");
return this.addVectors(v, w);
}
this.x += v.x;
this.y += v.y;
return this;
},
addScalar: function(s) {
this.x += s;
this.y += s;
return this;
},
addVectors: function(a, b) {
this.x = a.x + b.x;
this.y = a.y + b.y;
return this;
},
addScaledVector: function(v, s) {
this.x += v.x * s;
this.y += v.y * s;
return this;
},
sub: function(v, w) {
if (w !== void 0) {
console.warn("THREE.Vector2: .sub() now only accepts one argument. Use .subVectors( a, b ) instead.");
return this.subVectors(v, w);
}
this.x -= v.x;
this.y -= v.y;
return this;
},
subScalar: function(s) {
this.x -= s;
this.y -= s;
return this;
},
subVectors: function(a, b) {
this.x = a.x - b.x;
this.y = a.y - b.y;
return this;
},
multiply: function(v) {
this.x *= v.x;
this.y *= v.y;
return this;
},
multiplyScalar: function(scalar) {
this.x *= scalar;
this.y *= scalar;
return this;
},
divide: function(v) {
this.x /= v.x;
this.y /= v.y;
return this;
},
divideScalar: function(scalar) {
return this.multiplyScalar(1 / scalar);
},
applyMatrix3: function(m) {
var x = this.x, y = this.y;
var e = m.elements;
this.x = e[0] * x + e[3] * y + e[6];
this.y = e[1] * x + e[4] * y + e[7];
return this;
},
min: function(v) {
this.x = Math.min(this.x, v.x);
this.y = Math.min(this.y, v.y);
return this;
},
max: function(v) {
this.x = Math.max(this.x, v.x);
this.y = Math.max(this.y, v.y);
return this;
},
clamp: function(min, max) {
this.x = Math.max(min.x, Math.min(max.x, this.x));
this.y = Math.max(min.y, Math.min(max.y, this.y));
return this;
},
clampScalar: function(minVal, maxVal) {
this.x = Math.max(minVal, Math.min(maxVal, this.x));
this.y = Math.max(minVal, Math.min(maxVal, this.y));
return this;
},
clampLength: function(min, max) {
var length = this.length();
return this.divideScalar(length || 1).multiplyScalar(Math.max(min, Math.min(max, length)));
},
floor: function() {
this.x = Math.floor(this.x);
this.y = Math.floor(this.y);
return this;
},
ceil: function() {
this.x = Math.ceil(this.x);
this.y = Math.ceil(this.y);
return this;
},
round: function() {
this.x = Math.round(this.x);
this.y = Math.round(this.y);
return this;
},
roundToZero: function() {
this.x = this.x < 0 ? Math.ceil(this.x) : Math.floor(this.x);
this.y = this.y < 0 ? Math.ceil(this.y) : Math.floor(this.y);
return this;
},
negate: function() {
this.x = -this.x;
this.y = -this.y;
return this;
},
dot: function(v) {
return this.x * v.x + this.y * v.y;
},
cross: function(v) {
return this.x * v.y - this.y * v.x;
},
lengthSq: function() {
return this.x * this.x + this.y * this.y;
},
length: function() {
return Math.sqrt(this.x * this.x + this.y * this.y);
},
manhattanLength: function() {
return Math.abs(this.x) + Math.abs(this.y);
},
normalize: function() {
return this.divideScalar(this.length() || 1);
},
angle: function() {
var angle = Math.atan2(this.y, this.x);
if (angle < 0)
angle += 2 * Math.PI;
return angle;
},
distanceTo: function(v) {
return Math.sqrt(this.distanceToSquared(v));
},
distanceToSquared: function(v) {
var dx = this.x - v.x, dy = this.y - v.y;
return dx * dx + dy * dy;
},
manhattanDistanceTo: function(v) {
return Math.abs(this.x - v.x) + Math.abs(this.y - v.y);
},
setLength: function(length) {
return this.normalize().multiplyScalar(length);
},
lerp: function(v, alpha) {
this.x += (v.x - this.x) * alpha;
this.y += (v.y - this.y) * alpha;
return this;
},
lerpVectors: function(v1, v2, alpha) {
return this.subVectors(v2, v1).multiplyScalar(alpha).add(v1);
},
equals: function(v) {
return v.x === this.x && v.y === this.y;
},
fromArray: function(array, offset) {
if (offset === void 0)
offset = 0;
this.x = array[offset];
this.y = array[offset + 1];
return this;
},
toArray: function(array, offset) {
if (array === void 0)
array = [];
if (offset === void 0)
offset = 0;
array[offset] = this.x;
array[offset + 1] = this.y;
return array;
},
fromBufferAttribute: function(attribute, index, offset) {
if (offset !== void 0) {
console.warn("THREE.Vector2: offset has been removed from .fromBufferAttribute().");
}
this.x = attribute.getX(index);
this.y = attribute.getY(index);
return this;
},
rotateAround: function(center, angle) {
var c = Math.cos(angle), s = Math.sin(angle);
var x = this.x - center.x;
var y = this.y - center.y;
this.x = x * c - y * s + center.x;
this.y = x * s + y * c + center.y;
return this;
}
});
function Matrix3() {
this.elements = [
1,
0,
0,
0,
1,
0,
0,
0,
1
];
if (arguments.length > 0) {
console.error("THREE.Matrix3: the constructor no longer reads arguments. use .set() instead.");
}
}
Object.assign(Matrix3.prototype, {
isMatrix3: true,
set: function(n11, n12, n13, n21, n22, n23, n31, n32, n33) {
var te = this.elements;
te[0] = n11;
te[1] = n21;
te[2] = n31;
te[3] = n12;
te[4] = n22;
te[5] = n32;
te[6] = n13;
te[7] = n23;
te[8] = n33;
return this;
},
identity: function() {
this.set(
1,
0,
0,
0,
1,
0,
0,
0,
1
);
return this;
},
clone: function() {
return new this.constructor().fromArray(this.elements);
},
copy: function(m) {
var te = this.elements;
var me = m.elements;
te[0] = me[0];
te[1] = me[1];
te[2] = me[2];
te[3] = me[3];
te[4] = me[4];
te[5] = me[5];
te[6] = me[6];
te[7] = me[7];
te[8] = me[8];
return this;
},
setFromMatrix4: function(m) {
var me = m.elements;
this.set(
me[0],
me[4],
me[8],
me[1],
me[5],
me[9],
me[2],
me[6],
me[10]
);
return this;
},
multiply: function(m) {
return this.multiplyMatrices(this, m);
},
premultiply: function(m) {
return this.multiplyMatrices(m, this);
},
multiplyMatrices: function(a, b) {
var ae = a.elements;
var be = b.elements;
var te = this.elements;
var a11 = ae[0], a12 = ae[3], a13 = ae[6];
var a21 = ae[1], a22 = ae[4], a23 = ae[7];
var a31 = ae[2], a32 = ae[5], a33 = ae[8];
var b11 = be[0], b12 = be[3], b13 = be[6];
var b21 = be[1], b22 = be[4], b23 = be[7];
var b31 = be[2], b32 = be[5], b33 = be[8];
te[0] = a11 * b11 + a12 * b21 + a13 * b31;
te[3] = a11 * b12 + a12 * b22 + a13 * b32;
te[6] = a11 * b13 + a12 * b23 + a13 * b33;
te[1] = a21 * b11 + a22 * b21 + a23 * b31;
te[4] = a21 * b12 + a22 * b22 + a23 * b32;
te[7] = a21 * b13 + a22 * b23 + a23 * b33;
te[2] = a31 * b11 + a32 * b21 + a33 * b31;
te[5] = a31 * b12 + a32 * b22 + a33 * b32;
te[8] = a31 * b13 + a32 * b23 + a33 * b33;
return this;
},
multiplyScalar: function(s) {
var te = this.elements;
te[0] *= s;
te[3] *= s;
te[6] *= s;
te[1] *= s;
te[4] *= s;
te[7] *= s;
te[2] *= s;
te[5] *= s;
te[8] *= s;
return this;
},
determinant: function() {
var te = this.elements;
var a = te[0], b = te[1], c = te[2], d = te[3], e = te[4], f = te[5], g = te[6], h = te[7], i2 = te[8];
return a * e * i2 - a * f * h - b * d * i2 + b * f * g + c * d * h - c * e * g;
},
getInverse: function(matrix, throwOnDegenerate) {
if (matrix && matrix.isMatrix4) {
console.error("THREE.Matrix3: .getInverse() no longer takes a Matrix4 argument.");
}
var me = matrix.elements, te = this.elements, n11 = me[0], n21 = me[1], n31 = me[2], n12 = me[3], n22 = me[4], n32 = me[5], n13 = me[6], n23 = me[7], n33 = me[8], t11 = n33 * n22 - n32 * n23, t12 = n32 * n13 - n33 * n12, t13 = n23 * n12 - n22 * n13, det = n11 * t11 + n21 * t12 + n31 * t13;
if (det === 0) {
var msg = "THREE.Matrix3: .getInverse() can't invert matrix, determinant is 0";
if (throwOnDegenerate === true) {
throw new Error(msg);
} else {
console.warn(msg);
}
return this.identity();
}
var detInv = 1 / det;
te[0] = t11 * detInv;
te[1] = (n31 * n23 - n33 * n21) * detInv;
te[2] = (n32 * n21 - n31 * n22) * detInv;
te[3] = t12 * detInv;
te[4] = (n33 * n11 - n31 * n13) * detInv;
te[5] = (n31 * n12 - n32 * n11) * detInv;
te[6] = t13 * detInv;
te[7] = (n21 * n13 - n23 * n11) * detInv;
te[8] = (n22 * n11 - n21 * n12) * detInv;
return this;
},
transpose: function() {
var tmp2, m = this.elements;
tmp2 = m[1];
m[1] = m[3];
m[3] = tmp2;
tmp2 = m[2];
m[2] = m[6];
m[6] = tmp2;
tmp2 = m[5];
m[5] = m[7];
m[7] = tmp2;
return this;
},
getNormalMatrix: function(matrix4) {
return this.setFromMatrix4(matrix4).getInverse(this).transpose();
},
transposeIntoArray: function(r) {
var m = this.elements;
r[0] = m[0];
r[1] = m[3];
r[2] = m[6];
r[3] = m[1];
r[4] = m[4];
r[5] = m[7];
r[6] = m[2];
r[7] = m[5];
r[8] = m[8];
return this;
},
setUvTransform: function(tx, ty, sx, sy, rotation, cx, cy) {
var c = Math.cos(rotation);
var s = Math.sin(rotation);
this.set(
sx * c,
sx * s,
-sx * (c * cx + s * cy) + cx + tx,
-sy * s,
sy * c,
-sy * (-s * cx + c * cy) + cy + ty,
0,
0,
1
);
},
scale: function(sx, sy) {
var te = this.elements;
te[0] *= sx;
te[3] *= sx;
te[6] *= sx;
te[1] *= sy;
te[4] *= sy;
te[7] *= sy;
return this;
},
rotate: function(theta) {
var c = Math.cos(theta);
var s = Math.sin(theta);
var te = this.elements;
var a11 = te[0], a12 = te[3], a13 = te[6];
var a21 = te[1], a22 = te[4], a23 = te[7];
te[0] = c * a11 + s * a21;
te[3] = c * a12 + s * a22;
te[6] = c * a13 + s * a23;
te[1] = -s * a11 + c * a21;
te[4] = -s * a12 + c * a22;
te[7] = -s * a13 + c * a23;
return this;
},
translate: function(tx, ty) {
var te = this.elements;
te[0] += tx * te[2];
te[3] += tx * te[5];
te[6] += tx * te[8];
te[1] += ty * te[2];
te[4] += ty * te[5];
te[7] += ty * te[8];
return this;
},
equals: function(matrix) {
var te = this.elements;
var me = matrix.elements;
for (var i2 = 0; i2 < 9; i2++) {
if (te[i2] !== me[i2])
return false;
}
return true;
},
fromArray: function(array, offset) {
if (offset === void 0)
offset = 0;
for (var i2 = 0; i2 < 9; i2++) {
this.elements[i2] = array[i2 + offset];
}
return this;
},
toArray: function(array, offset) {
if (array === void 0)
array = [];
if (offset === void 0)
offset = 0;
var te = this.elements;
array[offset] = te[0];
array[offset + 1] = te[1];
array[offset + 2] = te[2];
array[offset + 3] = te[3];
array[offset + 4] = te[4];
array[offset + 5] = te[5];
array[offset + 6] = te[6];
array[offset + 7] = te[7];
array[offset + 8] = te[8];
return array;
}
});
var _canvas;
var ImageUtils = {
getDataURL: function(image) {
var canvas;
if (typeof HTMLCanvasElement == "undefined") {
return image.src;
} else if (image instanceof HTMLCanvasElement) {
canvas = image;
} else {
if (_canvas === void 0)
_canvas = document.createElementNS("http://www.w3.org/1999/xhtml", "canvas");
_canvas.width = image.width;
_canvas.height = image.height;
var context = _canvas.getContext("2d");
if (image instanceof ImageData) {
context.putImageData(image, 0, 0);
} else {
context.drawImage(image, 0, 0, image.width, image.height);
}
canvas = _canvas;
}
if (canvas.width > 2048 || canvas.height > 2048) {
return canvas.toDataURL("image/jpeg", 0.6);
} else {
return canvas.toDataURL("image/png");
}
}
};
var textureId = 0;
function Texture(image, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy, encoding) {
Object.defineProperty(this, "id", { value: textureId++ });
this.uuid = MathUtils.generateUUID();
this.name = "";
this.image = image !== void 0 ? image : Texture.DEFAULT_IMAGE;
this.mipmaps = [];
this.mapping = mapping !== void 0 ? mapping : Texture.DEFAULT_MAPPING;
this.wrapS = wrapS !== void 0 ? wrapS : ClampToEdgeWrapping;
this.wrapT = wrapT !== void 0 ? wrapT : ClampToEdgeWrapping;
this.magFilter = magFilter !== void 0 ? magFilter : LinearFilter;
this.minFilter = minFilter !== void 0 ? minFilter : LinearMipmapLinearFilter;
this.anisotropy = anisotropy !== void 0 ? anisotropy : 1;
this.format = format !== void 0 ? format : RGBAFormat;
this.internalFormat = null;
this.type = type !== void 0 ? type : UnsignedByteType;
this.offset = new Vector2(0, 0);
this.repeat = new Vector2(1, 1);
this.center = new Vector2(0, 0);
this.rotation = 0;
this.matrixAutoUpdate = true;
this.matrix = new Matrix3();
this.generateMipmaps = true;
this.premultiplyAlpha = false;
this.flipY = true;
this.unpackAlignment = 4;
this.encoding = encoding !== void 0 ? encoding : LinearEncoding;
this.version = 0;
this.onUpdate = null;
}
Texture.DEFAULT_IMAGE = void 0;
Texture.DEFAULT_MAPPING = UVMapping;
Texture.prototype = Object.assign(Object.create(EventDispatcher.prototype), {
constructor: Texture,
isTexture: true,
updateMatrix: function() {
this.matrix.setUvTransform(this.offset.x, this.offset.y, this.repeat.x, this.repeat.y, this.rotation, this.center.x, this.center.y);
},
clone: function() {
return new this.constructor().copy(this);
},
copy: function(source) {
this.name = source.name;
this.image = source.image;
this.mipmaps = source.mipmaps.slice(0);
this.mapping = source.mapping;
this.wrapS = source.wrapS;
this.wrapT = source.wrapT;
this.magFilter = source.magFilter;
this.minFilter = source.minFilter;
this.anisotropy = source.anisotropy;
this.format = source.format;
this.internalFormat = source.internalFormat;
this.type = source.type;
this.offset.copy(source.offset);
this.repeat.copy(source.repeat);
this.center.copy(source.center);
this.rotation = source.rotation;
this.matrixAutoUpdate = source.matrixAutoUpdate;
this.matrix.copy(source.matrix);
this.generateMipmaps = source.generateMipmaps;
this.premultiplyAlpha = source.premultiplyAlpha;
this.flipY = source.flipY;
this.unpackAlignment = source.unpackAlignment;
this.encoding = source.encoding;
return this;
},
toJSON: function(meta) {
var isRootObject = meta === void 0 || typeof meta === "string";
if (!isRootObject && meta.textures[this.uuid] !== void 0) {
return meta.textures[this.uuid];
}
var output = {
metadata: {
version: 4.5,
type: "Texture",
generator: "Texture.toJSON"
},
uuid: this.uuid,
name: this.name,
mapping: this.mapping,
repeat: [this.repeat.x, this.repeat.y],
offset: [this.offset.x, this.offset.y],
center: [this.center.x, this.center.y],
rotation: this.rotation,
wrap: [this.wrapS, this.wrapT],
format: this.format,
type: this.type,
encoding: this.encoding,
minFilter: this.minFilter,
magFilter: this.magFilter,
anisotropy: this.anisotropy,
flipY: this.flipY,
premultiplyAlpha: this.premultiplyAlpha,
unpackAlignment: this.unpackAlignment
};
if (this.image !== void 0) {
var image = this.image;
if (image.uuid === void 0) {
image.uuid = MathUtils.generateUUID();
}
if (!isRootObject && meta.images[image.uuid] === void 0) {
var url;
if (Array.isArray(image)) {
url = [];
for (var i2 = 0, l = image.length; i2 < l; i2++) {
url.push(ImageUtils.getDataURL(image[i2]));
}
} else {
url = ImageUtils.getDataURL(image);
}
meta.images[image.uuid] = {
uuid: image.uuid,
url
};
}
output.image = image.uuid;
}
if (!isRootObject) {
meta.textures[this.uuid] = output;
}
return output;
},
dispose: function() {
this.dispatchEvent({ type: "dispose" });
},
transformUv: function(uv) {
if (this.mapping !== UVMapping)
return uv;
uv.applyMatrix3(this.matrix);
if (uv.x < 0 || uv.x > 1) {
switch (this.wrapS) {
case RepeatWrapping:
uv.x = uv.x - Math.floor(uv.x);
break;
case ClampToEdgeWrapping:
uv.x = uv.x < 0 ? 0 : 1;
break;
case MirroredRepeatWrapping:
if (Math.abs(Math.floor(uv.x) % 2) === 1) {
uv.x = Math.ceil(uv.x) - uv.x;
} else {
uv.x = uv.x - Math.floor(uv.x);
}
break;
}
}
if (uv.y < 0 || uv.y > 1) {
switch (this.wrapT) {
case RepeatWrapping:
uv.y = uv.y - Math.floor(uv.y);
break;
case ClampToEdgeWrapping:
uv.y = uv.y < 0 ? 0 : 1;
break;
case MirroredRepeatWrapping:
if (Math.abs(Math.floor(uv.y) % 2) === 1) {
uv.y = Math.ceil(uv.y) - uv.y;
} else {
uv.y = uv.y - Math.floor(uv.y);
}
break;
}
}
if (this.flipY) {
uv.y = 1 - uv.y;
}
return uv;
}
});
Object.defineProperty(Texture.prototype, "needsUpdate", {
set: function(value) {
if (value === true)
this.version++;
}
});
function Vector4(x, y, z, w) {
this.x = x || 0;
this.y = y || 0;
this.z = z || 0;
this.w = w !== void 0 ? w : 1;
}
Object.defineProperties(Vector4.prototype, {
"width": {
get: function() {
return this.z;
},
set: function(value) {
this.z = value;
}
},
"height": {
get: function() {
return this.w;
},
set: function(value) {
this.w = value;
}
}
});
Object.assign(Vector4.prototype, {
isVector4: true,
set: function(x, y, z, w) {
this.x = x;
this.y = y;
this.z = z;
this.w = w;
return this;
},
setScalar: function(scalar) {
this.x = scalar;
this.y = scalar;
this.z = scalar;
this.w = scalar;
return this;
},
setX: function(x) {
this.x = x;
return this;
},
setY: function(y) {
this.y = y;
return this;
},
setZ: function(z) {
this.z = z;
return this;
},
setW: function(w) {
this.w = w;
return this;
},
setComponent: function(index, value) {
switch (index) {
case 0:
this.x = value;
break;
case 1:
this.y = value;
break;
case 2:
this.z = value;
break;
case 3:
this.w = value;
break;
default:
throw new Error("index is out of range: " + index);
}
return this;
},
getComponent: function(index) {
switch (index) {
case 0:
return this.x;
case 1:
return this.y;
case 2:
return this.z;
case 3:
return this.w;
default:
throw new Error("index is out of range: " + index);
}
},
clone: function() {
return new this.constructor(this.x, this.y, this.z, this.w);
},
copy: function(v) {
this.x = v.x;
this.y = v.y;
this.z = v.z;
this.w = v.w !== void 0 ? v.w : 1;
return this;
},
add: function(v, w) {
if (w !== void 0) {
console.warn("THREE.Vector4: .add() now only accepts one argument. Use .addVectors( a, b ) instead.");
return this.addVectors(v, w);
}
this.x += v.x;
this.y += v.y;
this.z += v.z;
this.w += v.w;
return this;
},
addScalar: function(s) {
this.x += s;
this.y += s;
this.z += s;
this.w += s;
return this;
},
addVectors: function(a, b) {
this.x = a.x + b.x;
this.y = a.y + b.y;
this.z = a.z + b.z;
this.w = a.w + b.w;
return this;
},
addScaledVector: function(v, s) {
this.x += v.x * s;
this.y += v.y * s;
this.z += v.z * s;
this.w += v.w * s;
return this;
},
sub: function(v, w) {
if (w !== void 0) {
console.warn("THREE.Vector4: .sub() now only accepts one argument. Use .subVectors( a, b ) instead.");
return this.subVectors(v, w);
}
this.x -= v.x;
this.y -= v.y;
this.z -= v.z;
this.w -= v.w;
return this;
},
subScalar: function(s) {
this.x -= s;
this.y -= s;
this.z -= s;
this.w -= s;
return this;
},
subVectors: function(a, b) {
this.x = a.x - b.x;
this.y = a.y - b.y;
this.z = a.z - b.z;
this.w = a.w - b.w;
return this;
},
multiplyScalar: function(scalar) {
this.x *= scalar;
this.y *= scalar;
this.z *= scalar;
this.w *= scalar;
return this;
},
applyMatrix4: function(m) {
var x = this.x, y = this.y, z = this.z, w = this.w;
var e = m.elements;
this.x = e[0] * x + e[4] * y + e[8] * z + e[12] * w;
this.y = e[1] * x + e[5] * y + e[9] * z + e[13] * w;
this.z = e[2] * x + e[6] * y + e[10] * z + e[14] * w;
this.w = e[3] * x + e[7] * y + e[11] * z + e[15] * w;
return this;
},
divideScalar: function(scalar) {
return this.multiplyScalar(1 / scalar);
},
setAxisAngleFromQuaternion: function(q) {
this.w = 2 * Math.acos(q.w);
var s = Math.sqrt(1 - q.w * q.w);
if (s < 1e-4) {
this.x = 1;
this.y = 0;
this.z = 0;
} else {
this.x = q.x / s;
this.y = q.y / s;
this.z = q.z / s;
}
return this;
},
setAxisAngleFromRotationMatrix: function(m) {
var angle, x, y, z, epsilon = 0.01, epsilon2 = 0.1, te = m.elements, m11 = te[0], m12 = te[4], m13 = te[8], m21 = te[1], m22 = te[5], m23 = te[9], m31 = te[2], m32 = te[6], m33 = te[10];
if (Math.abs(m12 - m21) < epsilon && Math.abs(m13 - m31) < epsilon && Math.abs(m23 - m32) < epsilon) {
if (Math.abs(m12 + m21) < epsilon2 && Math.abs(m13 + m31) < epsilon2 && Math.abs(m23 + m32) < epsilon2 && Math.abs(m11 + m22 + m33 - 3) < epsilon2) {
this.set(1, 0, 0, 0);
return this;
}
angle = Math.PI;
var xx = (m11 + 1) / 2;
var yy = (m22 + 1) / 2;
var zz = (m33 + 1) / 2;
var xy = (m12 + m21) / 4;
var xz = (m13 + m31) / 4;
var yz = (m23 + m32) / 4;
if (xx > yy && xx > zz) {
if (xx < epsilon) {
x = 0;
y = 0.707106781;
z = 0.707106781;
} else {
x = Math.sqrt(xx);
y = xy / x;
z = xz / x;
}
} else if (yy > zz) {
if (yy < epsilon) {
x = 0.707106781;
y = 0;
z = 0.707106781;
} else {
y = Math.sqrt(yy);
x = xy / y;
z = yz / y;
}
} else {
if (zz < epsilon) {
x = 0.707106781;
y = 0.707106781;
z = 0;
} else {
z = Math.sqrt(zz);
x = xz / z;
y = yz / z;
}
}
this.set(x, y, z, angle);
return this;
}
var s = Math.sqrt((m32 - m23) * (m32 - m23) + (m13 - m31) * (m13 - m31) + (m21 - m12) * (m21 - m12));
if (Math.abs(s) < 1e-3)
s = 1;
this.x = (m32 - m23) / s;
this.y = (m13 - m31) / s;
this.z = (m21 - m12) / s;
this.w = Math.acos((m11 + m22 + m33 - 1) / 2);
return this;
},
min: function(v) {
this.x = Math.min(this.x, v.x);
this.y = Math.min(this.y, v.y);
this.z = Math.min(this.z, v.z);
this.w = Math.min(this.w, v.w);
return this;
},
max: function(v) {
this.x = Math.max(this.x, v.x);
this.y = Math.max(this.y, v.y);
this.z = Math.max(this.z, v.z);
this.w = Math.max(this.w, v.w);
return this;
},
clamp: function(min, max) {
this.x = Math.max(min.x, Math.min(max.x, this.x));
this.y = Math.max(min.y, Math.min(max.y, this.y));
this.z = Math.max(min.z, Math.min(max.z, this.z));
this.w = Math.max(min.w, Math.min(max.w, this.w));
return this;
},
clampScalar: function(minVal, maxVal) {
this.x = Math.max(minVal, Math.min(maxVal, this.x));
this.y = Math.max(minVal, Math.min(maxVal, this.y));
this.z = Math.max(minVal, Math.min(maxVal, this.z));
this.w = Math.max(minVal, Math.min(maxVal, this.w));
return this;
},
clampLength: function(min, max) {
var length = this.length();
return this.divideScalar(length || 1).multiplyScalar(Math.max(min, Math.min(max, length)));
},
floor: function() {
this.x = Math.floor(this.x);
this.y = Math.floor(this.y);
this.z = Math.floor(this.z);
this.w = Math.floor(this.w);
return this;
},
ceil: function() {
this.x = Math.ceil(this.x);
this.y = Math.ceil(this.y);
this.z = Math.ceil(this.z);
this.w = Math.ceil(this.w);
return this;
},
round: function() {
this.x = Math.round(this.x);
this.y = Math.round(this.y);
this.z = Math.round(this.z);
this.w = Math.round(this.w);
return this;
},
roundToZero: function() {
this.x = this.x < 0 ? Math.ceil(this.x) : Math.floor(this.x);
this.y = this.y < 0 ? Math.ceil(this.y) : Math.floor(this.y);
this.z = this.z < 0 ? Math.ceil(this.z) : Math.floor(this.z);
this.w = this.w < 0 ? Math.ceil(this.w) : Math.floor(this.w);
return this;
},
negate: function() {
this.x = -this.x;
this.y = -this.y;
this.z = -this.z;
this.w = -this.w;
return this;
},
dot: function(v) {
return this.x * v.x + this.y * v.y + this.z * v.z + this.w * v.w;
},
lengthSq: function() {
return this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w;
},
length: function() {
return Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w);
},
manhattanLength: function() {
return Math.abs(this.x) + Math.abs(this.y) + Math.abs(this.z) + Math.abs(this.w);
},
normalize: function() {
return this.divideScalar(this.length() || 1);
},
setLength: function(length) {
return this.normalize().multiplyScalar(length);
},
lerp: function(v, alpha) {
this.x += (v.x - this.x) * alpha;
this.y += (v.y - this.y) * alpha;
this.z += (v.z - this.z) * alpha;
this.w += (v.w - this.w) * alpha;
return this;
},
lerpVectors: function(v1, v2, alpha) {
return this.subVectors(v2, v1).multiplyScalar(alpha).add(v1);
},
equals: function(v) {
return v.x === this.x && v.y === this.y && v.z === this.z && v.w === this.w;
},
fromArray: function(array, offset) {
if (offset === void 0)
offset = 0;
this.x = array[offset];
this.y = array[offset + 1];
this.z = array[offset + 2];
this.w = array[offset + 3];
return this;
},
toArray: function(array, offset) {
if (array === void 0)
array = [];
if (offset === void 0)
offset = 0;
array[offset] = this.x;
array[offset + 1] = this.y;
array[offset + 2] = this.z;
array[offset + 3] = this.w;
return array;
},
fromBufferAttribute: function(attribute, index, offset) {
if (offset !== void 0) {
console.warn("THREE.Vector4: offset has been removed from .fromBufferAttribute().");
}
this.x = attribute.getX(index);
this.y = attribute.getY(index);
this.z = attribute.getZ(index);
this.w = attribute.getW(index);
return this;
}
});
function WebGLRenderTarget(width, height, options) {
this.width = width;
this.height = height;
this.scissor = new Vector4(0, 0, width, height);
this.scissorTest = false;
this.viewport = new Vector4(0, 0, width, height);
options = options || {};
this.texture = new Texture(void 0, options.mapping, options.wrapS, options.wrapT, options.magFilter, options.minFilter, options.format, options.type, options.anisotropy, options.encoding);
this.texture.image = {};
this.texture.image.width = width;
this.texture.image.height = height;
this.texture.generateMipmaps = options.generateMipmaps !== void 0 ? options.generateMipmaps : false;
this.texture.minFilter = options.minFilter !== void 0 ? options.minFilter : LinearFilter;
this.depthBuffer = options.depthBuffer !== void 0 ? options.depthBuffer : true;
this.stencilBuffer = options.stencilBuffer !== void 0 ? options.stencilBuffer : true;
this.depthTexture = options.depthTexture !== void 0 ? options.depthTexture : null;
}
WebGLRenderTarget.prototype = Object.assign(Object.create(EventDispatcher.prototype), {
constructor: WebGLRenderTarget,
isWebGLRenderTarget: true,
setSize: function(width, height) {
if (this.width !== width || this.height !== height) {
this.width = width;
this.height = height;
this.texture.image.width = width;
this.texture.image.height = height;
this.dispose();
}
this.viewport.set(0, 0, width, height);
this.scissor.set(0, 0, width, height);
},
clone: function() {
return new this.constructor().copy(this);
},
copy: function(source) {
this.width = source.width;
this.height = source.height;
this.viewport.copy(source.viewport);
this.texture = source.texture.clone();
this.depthBuffer = source.depthBuffer;
this.stencilBuffer = source.stencilBuffer;
this.depthTexture = source.depthTexture;
return this;
},
dispose: function() {
this.dispatchEvent({ type: "dispose" });
}
});
function WebGLMultisampleRenderTarget(width, height, options) {
WebGLRenderTarget.call(this, width, height, options);
this.samples = 4;
}
WebGLMultisampleRenderTarget.prototype = Object.assign(Object.create(WebGLRenderTarget.prototype), {
constructor: WebGLMultisampleRenderTarget,
isWebGLMultisampleRenderTarget: true,
copy: function(source) {
WebGLRenderTarget.prototype.copy.call(this, source);
this.samples = source.samples;
return this;
}
});
function Quaternion(x, y, z, w) {
this._x = x || 0;
this._y = y || 0;
this._z = z || 0;
this._w = w !== void 0 ? w : 1;
}
Object.assign(Quaternion, {
slerp: function(qa, qb, qm, t) {
return qm.copy(qa).slerp(qb, t);
},
slerpFlat: function(dst, dstOffset, src0, srcOffset0, src1, srcOffset1, t) {
var x0 = src0[srcOffset0 + 0], y0 = src0[srcOffset0 + 1], z0 = src0[srcOffset0 + 2], w0 = src0[srcOffset0 + 3], x1 = src1[srcOffset1 + 0], y1 = src1[srcOffset1 + 1], z1 = src1[srcOffset1 + 2], w1 = src1[srcOffset1 + 3];
if (w0 !== w1 || x0 !== x1 || y0 !== y1 || z0 !== z1) {
var s = 1 - t, cos = x0 * x1 + y0 * y1 + z0 * z1 + w0 * w1, dir = cos >= 0 ? 1 : -1, sqrSin = 1 - cos * cos;
if (sqrSin > Number.EPSILON) {
var sin = Math.sqrt(sqrSin), len = Math.atan2(sin, cos * dir);
s = Math.sin(s * len) / sin;
t = Math.sin(t * len) / sin;
}
var tDir = t * dir;
x0 = x0 * s + x1 * tDir;
y0 = y0 * s + y1 * tDir;
z0 = z0 * s + z1 * tDir;
w0 = w0 * s + w1 * tDir;
if (s === 1 - t) {
var f = 1 / Math.sqrt(x0 * x0 + y0 * y0 + z0 * z0 + w0 * w0);
x0 *= f;
y0 *= f;
z0 *= f;
w0 *= f;
}
}
dst[dstOffset] = x0;
dst[dstOffset + 1] = y0;
dst[dstOffset + 2] = z0;
dst[dstOffset + 3] = w0;
}
});
Object.defineProperties(Quaternion.prototype, {
x: {
get: function() {
return this._x;
},
set: function(value) {
this._x = value;
this._onChangeCallback();
}
},
y: {
get: function() {
return this._y;
},
set: function(value) {
this._y = value;
this._onChangeCallback();
}
},
z: {
get: function() {
return this._z;
},
set: function(value) {
this._z = value;
this._onChangeCallback();
}
},
w: {
get: function() {
return this._w;
},
set: function(value) {
this._w = value;
this._onChangeCallback();
}
}
});
Object.assign(Quaternion.prototype, {
isQuaternion: true,
set: function(x, y, z, w) {
this._x = x;
this._y = y;
this._z = z;
this._w = w;
this._onChangeCallback();
return this;
},
clone: function() {
return new this.constructor(this._x, this._y, this._z, this._w);
},
copy: function(quaternion) {
this._x = quaternion.x;
this._y = quaternion.y;
this._z = quaternion.z;
this._w = quaternion.w;
this._onChangeCallback();
return this;
},
setFromEuler: function(euler, update) {
if (!(euler && euler.isEuler)) {
throw new Error("THREE.Quaternion: .setFromEuler() now expects an Euler rotation rather than a Vector3 and order.");
}
var x = euler._x, y = euler._y, z = euler._z, order = euler.order;
var cos = Math.cos;
var sin = Math.sin;
var c1 = cos(x / 2);
var c2 = cos(y / 2);
var c3 = cos(z / 2);
var s1 = sin(x / 2);
var s2 = sin(y / 2);
var s3 = sin(z / 2);
if (order === "XYZ") {
this._x = s1 * c2 * c3 + c1 * s2 * s3;
this._y = c1 * s2 * c3 - s1 * c2 * s3;
this._z = c1 * c2 * s3 + s1 * s2 * c3;
this._w = c1 * c2 * c3 - s1 * s2 * s3;
} else if (order === "YXZ") {
this._x = s1 * c2 * c3 + c1 * s2 * s3;
this._y = c1 * s2 * c3 - s1 * c2 * s3;
this._z = c1 * c2 * s3 - s1 * s2 * c3;
this._w = c1 * c2 * c3 + s1 * s2 * s3;
} else if (order === "ZXY") {
this._x = s1 * c2 * c3 - c1 * s2 * s3;
this._y = c1 * s2 * c3 + s1 * c2 * s3;
this._z = c1 * c2 * s3 + s1 * s2 * c3;
this._w = c1 * c2 * c3 - s1 * s2 * s3;
} else if (order === "ZYX") {
this._x = s1 * c2 * c3 - c1 * s2 * s3;
this._y = c1 * s2 * c3 + s1 * c2 * s3;
this._z = c1 * c2 * s3 - s1 * s2 * c3;
this._w = c1 * c2 * c3 + s1 * s2 * s3;
} else if (order === "YZX") {
this._x = s1 * c2 * c3 + c1 * s2 * s3;
this._y = c1 * s2 * c3 + s1 * c2 * s3;
this._z = c1 * c2 * s3 - s1 * s2 * c3;
this._w = c1 * c2 * c3 - s1 * s2 * s3;
} else if (order === "XZY") {
this._x = s1 * c2 * c3 - c1 * s2 * s3;
this._y = c1 * s2 * c3 - s1 * c2 * s3;
this._z = c1 * c2 * s3 + s1 * s2 * c3;
this._w = c1 * c2 * c3 + s1 * s2 * s3;
}
if (update !== false)
this._onChangeCallback();
return this;
},
setFromAxisAngle: function(axis, angle) {
var halfAngle = angle / 2, s = Math.sin(halfAngle);
this._x = axis.x * s;
this._y = axis.y * s;
this._z = axis.z * s;
this._w = Math.cos(halfAngle);
this._onChangeCallback();
return this;
},
setFromRotationMatrix: function(m) {
var te = m.elements, m11 = te[0], m12 = te[4], m13 = te[8], m21 = te[1], m22 = te[5], m23 = te[9], m31 = te[2], m32 = te[6], m33 = te[10], trace = m11 + m22 + m33, s;
if (trace > 0) {
s = 0.5 / Math.sqrt(trace + 1);
this._w = 0.25 / s;
this._x = (m32 - m23) * s;
this._y = (m13 - m31) * s;
this._z = (m21 - m12) * s;
} else if (m11 > m22 && m11 > m33) {
s = 2 * Math.sqrt(1 + m11 - m22 - m33);
this._w = (m32 - m23) / s;
this._x = 0.25 * s;
this._y = (m12 + m21) / s;
this._z = (m13 + m31) / s;
} else if (m22 > m33) {
s = 2 * Math.sqrt(1 + m22 - m11 - m33);
this._w = (m13 - m31) / s;
this._x = (m12 + m21) / s;
this._y = 0.25 * s;
this._z = (m23 + m32) / s;
} else {
s = 2 * Math.sqrt(1 + m33 - m11 - m22);
this._w = (m21 - m12) / s;
this._x = (m13 + m31) / s;
this._y = (m23 + m32) / s;
this._z = 0.25 * s;
}
this._onChangeCallback();
return this;
},
setFromUnitVectors: function(vFrom, vTo) {
var EPS = 1e-6;
var r = vFrom.dot(vTo) + 1;
if (r < EPS) {
r = 0;
if (Math.abs(vFrom.x) > Math.abs(vFrom.z)) {
this._x = -vFrom.y;
this._y = vFrom.x;
this._z = 0;
this._w = r;
} else {
this._x = 0;
this._y = -vFrom.z;
this._z = vFrom.y;
this._w = r;
}
} else {
this._x = vFrom.y * vTo.z - vFrom.z * vTo.y;
this._y = vFrom.z * vTo.x - vFrom.x * vTo.z;
this._z = vFrom.x * vTo.y - vFrom.y * vTo.x;
this._w = r;
}
return this.normalize();
},
angleTo: function(q) {
return 2 * Math.acos(Math.abs(MathUtils.clamp(this.dot(q), -1, 1)));
},
rotateTowards: function(q, step) {
var angle = this.angleTo(q);
if (angle === 0)
return this;
var t = Math.min(1, step / angle);
this.slerp(q, t);
return this;
},
inverse: function() {
return this.conjugate();
},
conjugate: function() {
this._x *= -1;
this._y *= -1;
this._z *= -1;
this._onChangeCallback();
return this;
},
dot: function(v) {
return this._x * v._x + this._y * v._y + this._z * v._z + this._w * v._w;
},
lengthSq: function() {
return this._x * this._x + this._y * this._y + this._z * this._z + this._w * this._w;
},
length: function() {
return Math.sqrt(this._x * this._x + this._y * this._y + this._z * this._z + this._w * this._w);
},
normalize: function() {
var l = this.length();
if (l === 0) {
this._x = 0;
this._y = 0;
this._z = 0;
this._w = 1;
} else {
l = 1 / l;
this._x = this._x * l;
this._y = this._y * l;
this._z = this._z * l;
this._w = this._w * l;
}
this._onChangeCallback();
return this;
},
multiply: function(q, p) {
if (p !== void 0) {
console.warn("THREE.Quaternion: .multiply() now only accepts one argument. Use .multiplyQuaternions( a, b ) instead.");
return this.multiplyQuaternions(q, p);
}
return this.multiplyQuaternions(this, q);
},
premultiply: function(q) {
return this.multiplyQuaternions(q, this);
},
multiplyQuaternions: function(a, b) {
var qax = a._x, qay = a._y, qaz = a._z, qaw = a._w;
var qbx = b._x, qby = b._y, qbz = b._z, qbw = b._w;
this._x = qax * qbw + qaw * qbx + qay * qbz - qaz * qby;
this._y = qay * qbw + qaw * qby + qaz * qbx - qax * qbz;
this._z = qaz * qbw + qaw * qbz + qax * qby - qay * qbx;
this._w = qaw * qbw - qax * qbx - qay * qby - qaz * qbz;
this._onChangeCallback();
return this;
},
slerp: function(qb, t) {
if (t === 0)
return this;
if (t === 1)
return this.copy(qb);
var x = this._x, y = this._y, z = this._z, w = this._w;
var cosHalfTheta = w * qb._w + x * qb._x + y * qb._y + z * qb._z;
if (cosHalfTheta < 0) {
this._w = -qb._w;
this._x = -qb._x;
this._y = -qb._y;
this._z = -qb._z;
cosHalfTheta = -cosHalfTheta;
} else {
this.copy(qb);
}
if (cosHalfTheta >= 1) {
this._w = w;
this._x = x;
this._y = y;
this._z = z;
return this;
}
var sqrSinHalfTheta = 1 - cosHalfTheta * cosHalfTheta;
if (sqrSinHalfTheta <= Number.EPSILON) {
var s = 1 - t;
this._w = s * w + t * this._w;
this._x = s * x + t * this._x;
this._y = s * y + t * this._y;
this._z = s * z + t * this._z;
this.normalize();
this._onChangeCallback();
return this;
}
var sinHalfTheta = Math.sqrt(sqrSinHalfTheta);
var halfTheta = Math.atan2(sinHalfTheta, cosHalfTheta);
var ratioA = Math.sin((1 - t) * halfTheta) / sinHalfTheta, ratioB = Math.sin(t * halfTheta) / sinHalfTheta;
this._w = w * ratioA + this._w * ratioB;
this._x = x * ratioA + this._x * ratioB;
this._y = y * ratioA + this._y * ratioB;
this._z = z * ratioA + this._z * ratioB;
this._onChangeCallback();
return this;
},
equals: function(quaternion) {
return quaternion._x === this._x && quaternion._y === this._y && quaternion._z === this._z && quaternion._w === this._w;
},
fromArray: function(array, offset) {
if (offset === void 0)
offset = 0;
this._x = array[offset];
this._y = array[offset + 1];
this._z = array[offset + 2];
this._w = array[offset + 3];
this._onChangeCallback();
return this;
},
toArray: function(array, offset) {
if (array === void 0)
array = [];
if (offset === void 0)
offset = 0;
array[offset] = this._x;
array[offset + 1] = this._y;
array[offset + 2] = this._z;
array[offset + 3] = this._w;
return array;
},
_onChange: function(callback) {
this._onChangeCallback = callback;
return this;
},
_onChangeCallback: function() {
}
});
var _vector = new Vector3();
var _quaternion = new Quaternion();
function Vector3(x, y, z) {
this.x = x || 0;
this.y = y || 0;
this.z = z || 0;
}
Object.assign(Vector3.prototype, {
isVector3: true,
set: function(x, y, z) {
this.x = x;
this.y = y;
this.z = z;
return this;
},
setScalar: function(scalar) {
this.x = scalar;
this.y = scalar;
this.z = scalar;
return this;
},
setX: function(x) {
this.x = x;
return this;
},
setY: function(y) {
this.y = y;
return this;
},
setZ: function(z) {
this.z = z;
return this;
},
setComponent: function(index, value) {
switch (index) {
case 0:
this.x = value;
break;
case 1:
this.y = value;
break;
case 2:
this.z = value;
break;
default:
throw new Error("index is out of range: " + index);
}
return this;
},
getComponent: function(index) {
switch (index) {
case 0:
return this.x;
case 1:
return this.y;
case 2:
return this.z;
default:
throw new Error("index is out of range: " + index);
}
},
clone: function() {
return new this.constructor(this.x, this.y, this.z);
},
copy: function(v) {
this.x = v.x;
this.y = v.y;
this.z = v.z;
return this;
},
add: function(v, w) {
if (w !== void 0) {
console.warn("THREE.Vector3: .add() now only accepts one argument. Use .addVectors( a, b ) instead.");
return this.addVectors(v, w);
}
this.x += v.x;
this.y += v.y;
this.z += v.z;
return this;
},
addScalar: function(s) {
this.x += s;
this.y += s;
this.z += s;
return this;
},
addVectors: function(a, b) {
this.x = a.x + b.x;
this.y = a.y + b.y;
this.z = a.z + b.z;
return this;
},
addScaledVector: function(v, s) {
this.x += v.x * s;
this.y += v.y * s;
this.z += v.z * s;
return this;
},
sub: function(v, w) {
if (w !== void 0) {
console.warn("THREE.Vector3: .sub() now only accepts one argument. Use .subVectors( a, b ) instead.");
return this.subVectors(v, w);
}
this.x -= v.x;
this.y -= v.y;
this.z -= v.z;
return this;
},
subScalar: function(s) {
this.x -= s;
this.y -= s;
this.z -= s;
return this;
},
subVectors: function(a, b) {
this.x = a.x - b.x;
this.y = a.y - b.y;
this.z = a.z - b.z;
return this;
},
multiply: function(v, w) {
if (w !== void 0) {
console.warn("THREE.Vector3: .multiply() now only accepts one argument. Use .multiplyVectors( a, b ) instead.");
return this.multiplyVectors(v, w);
}
this.x *= v.x;
this.y *= v.y;
this.z *= v.z;
return this;
},
multiplyScalar: function(scalar) {
this.x *= scalar;
this.y *= scalar;
this.z *= scalar;
return this;
},
multiplyVectors: function(a, b) {
this.x = a.x * b.x;
this.y = a.y * b.y;
this.z = a.z * b.z;
return this;
},
applyEuler: function(euler) {
if (!(euler && euler.isEuler)) {
console.error("THREE.Vector3: .applyEuler() now expects an Euler rotation rather than a Vector3 and order.");
}
return this.applyQuaternion(_quaternion.setFromEuler(euler));
},
applyAxisAngle: function(axis, angle) {
return this.applyQuaternion(_quaternion.setFromAxisAngle(axis, angle));
},
applyMatrix3: function(m) {
var x = this.x, y = this.y, z = this.z;
var e = m.elements;
this.x = e[0] * x + e[3] * y + e[6] * z;
this.y = e[1] * x + e[4] * y + e[7] * z;
this.z = e[2] * x + e[5] * y + e[8] * z;
return this;
},
applyNormalMatrix: function(m) {
return this.applyMatrix3(m).normalize();
},
applyMatrix4: function(m) {
var x = this.x, y = this.y, z = this.z;
var e = m.elements;
var w = 1 / (e[3] * x + e[7] * y + e[11] * z + e[15]);
this.x = (e[0] * x + e[4] * y + e[8] * z + e[12]) * w;
this.y = (e[1] * x + e[5] * y + e[9] * z + e[13]) * w;
this.z = (e[2] * x + e[6] * y + e[10] * z + e[14]) * w;
return this;
},
applyQuaternion: function(q) {
var x = this.x, y = this.y, z = this.z;
var qx = q.x, qy = q.y, qz = q.z, qw = q.w;
var ix = qw * x + qy * z - qz * y;
var iy = qw * y + qz * x - qx * z;
var iz = qw * z + qx * y - qy * x;
var iw = -qx * x - qy * y - qz * z;
this.x = ix * qw + iw * -qx + iy * -qz - iz * -qy;
this.y = iy * qw + iw * -qy + iz * -qx - ix * -qz;
this.z = iz * qw + iw * -qz + ix * -qy - iy * -qx;
return this;
},
project: function(camera) {
return this.applyMatrix4(camera.matrixWorldInverse).applyMatrix4(camera.projectionMatrix);
},
unproject: function(camera) {
return this.applyMatrix4(camera.projectionMatrixInverse).applyMatrix4(camera.matrixWorld);
},
transformDirection: function(m) {
var x = this.x, y = this.y, z = this.z;
var e = m.elements;
this.x = e[0] * x + e[4] * y + e[8] * z;
this.y = e[1] * x + e[5] * y + e[9] * z;
this.z = e[2] * x + e[6] * y + e[10] * z;
return this.normalize();
},
divide: function(v) {
this.x /= v.x;
this.y /= v.y;
this.z /= v.z;
return this;
},
divideScalar: function(scalar) {
return this.multiplyScalar(1 / scalar);
},
min: function(v) {
this.x = Math.min(this.x, v.x);
this.y = Math.min(this.y, v.y);
this.z = Math.min(this.z, v.z);
return this;
},
max: function(v) {
this.x = Math.max(this.x, v.x);
this.y = Math.max(this.y, v.y);
this.z = Math.max(this.z, v.z);
return this;
},
clamp: function(min, max) {
this.x = Math.max(min.x, Math.min(max.x, this.x));
this.y = Math.max(min.y, Math.min(max.y, this.y));
this.z = Math.max(min.z, Math.min(max.z, this.z));
return this;
},
clampScalar: function(minVal, maxVal) {
this.x = Math.max(minVal, Math.min(maxVal, this.x));
this.y = Math.max(minVal, Math.min(maxVal, this.y));
this.z = Math.max(minVal, Math.min(maxVal, this.z));
return this;
},
clampLength: function(min, max) {
var length = this.length();
return this.divideScalar(length || 1).multiplyScalar(Math.max(min, Math.min(max, length)));
},
floor: function() {
this.x = Math.floor(this.x);
this.y = Math.floor(this.y);
this.z = Math.floor(this.z);
return this;
},
ceil: function() {
this.x = Math.ceil(this.x);
this.y = Math.ceil(this.y);
this.z = Math.ceil(this.z);
return this;
},
round: function() {
this.x = Math.round(this.x);
this.y = Math.round(this.y);
this.z = Math.round(this.z);
return this;
},
roundToZero: function() {
this.x = this.x < 0 ? Math.ceil(this.x) : Math.floor(this.x);
this.y = this.y < 0 ? Math.ceil(this.y) : Math.floor(this.y);
this.z = this.z < 0 ? Math.ceil(this.z) : Math.floor(this.z);
return this;
},
negate: function() {
this.x = -this.x;
this.y = -this.y;
this.z = -this.z;
return this;
},
dot: function(v) {
return this.x * v.x + this.y * v.y + this.z * v.z;
},
// TODO lengthSquared?
lengthSq: function() {
return this.x * this.x + this.y * this.y + this.z * this.z;
},
length: function() {
return Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z);
},
manhattanLength: function() {
return Math.abs(this.x) + Math.abs(this.y) + Math.abs(this.z);
},
normalize: function() {
return this.divideScalar(this.length() || 1);
},
setLength: function(length) {
return this.normalize().multiplyScalar(length);
},
lerp: function(v, alpha) {
this.x += (v.x - this.x) * alpha;
this.y += (v.y - this.y) * alpha;
this.z += (v.z - this.z) * alpha;
return this;
},
lerpVectors: function(v1, v2, alpha) {
return this.subVectors(v2, v1).multiplyScalar(alpha).add(v1);
},
cross: function(v, w) {
if (w !== void 0) {
console.warn("THREE.Vector3: .cross() now only accepts one argument. Use .crossVectors( a, b ) instead.");
return this.crossVectors(v, w);
}
return this.crossVectors(this, v);
},
crossVectors: function(a, b) {
var ax = a.x, ay = a.y, az = a.z;
var bx = b.x, by = b.y, bz = b.z;
this.x = ay * bz - az * by;
this.y = az * bx - ax * bz;
this.z = ax * by - ay * bx;
return this;
},
projectOnVector: function(v) {
var denominator = v.lengthSq();
if (denominator === 0)
return this.set(0, 0, 0);
var scalar = v.dot(this) / denominator;
return this.copy(v).multiplyScalar(scalar);
},
projectOnPlane: function(planeNormal) {
_vector.copy(this).projectOnVector(planeNormal);
return this.sub(_vector);
},
reflect: function(normal) {
return this.sub(_vector.copy(normal).multiplyScalar(2 * this.dot(normal)));
},
angleTo: function(v) {
var denominator = Math.sqrt(this.lengthSq() * v.lengthSq());
if (denominator === 0)
return Math.PI / 2;
var theta = this.dot(v) / denominator;
return Math.acos(MathUtils.clamp(theta, -1, 1));
},
distanceTo: function(v) {
return Math.sqrt(this.distanceToSquared(v));
},
distanceToSquared: function(v) {
var dx = this.x - v.x, dy = this.y - v.y, dz = this.z - v.z;
return dx * dx + dy * dy + dz * dz;
},
manhattanDistanceTo: function(v) {
return Math.abs(this.x - v.x) + Math.abs(this.y - v.y) + Math.abs(this.z - v.z);
},
setFromSpherical: function(s) {
return this.setFromSphericalCoords(s.radius, s.phi, s.theta);
},
setFromSphericalCoords: function(radius, phi, theta) {
var sinPhiRadius = Math.sin(phi) * radius;
this.x = sinPhiRadius * Math.sin(theta);
this.y = Math.cos(phi) * radius;
this.z = sinPhiRadius * Math.cos(theta);
return this;
},
setFromCylindrical: function(c) {
return this.setFromCylindricalCoords(c.radius, c.theta, c.y);
},
setFromCylindricalCoords: function(radius, theta, y) {
this.x = radius * Math.sin(theta);
this.y = y;
this.z = radius * Math.cos(theta);
return this;
},
setFromMatrixPosition: function(m) {
var e = m.elements;
this.x = e[12];
this.y = e[13];
this.z = e[14];
return this;
},
setFromMatrixScale: function(m) {
var sx = this.setFromMatrixColumn(m, 0).length();
var sy = this.setFromMatrixColumn(m, 1).length();
var sz = this.setFromMatrixColumn(m, 2).length();
this.x = sx;
this.y = sy;
this.z = sz;
return this;
},
setFromMatrixColumn: function(m, index) {
return this.fromArray(m.elements, index * 4);
},
setFromMatrix3Column: function(m, index) {
return this.fromArray(m.elements, index * 3);
},
equals: function(v) {
return v.x === this.x && v.y === this.y && v.z === this.z;
},
fromArray: function(array, offset) {
if (offset === void 0)
offset = 0;
this.x = array[offset];
this.y = array[offset + 1];
this.z = array[offset + 2];
return this;
},
toArray: function(array, offset) {
if (array === void 0)
array = [];
if (offset === void 0)
offset = 0;
array[offset] = this.x;
array[offset + 1] = this.y;
array[offset + 2] = this.z;
return array;
},
fromBufferAttribute: function(attribute, index, offset) {
if (offset !== void 0) {
console.warn("THREE.Vector3: offset has been removed from .fromBufferAttribute().");
}
this.x = attribute.getX(index);
this.y = attribute.getY(index);
this.z = attribute.getZ(index);
return this;
}
});
var _v1 = new Vector3();
var _m1 = new Matrix4();
var _zero = new Vector3(0, 0, 0);
var _one = new Vector3(1, 1, 1);
var _x = new Vector3();
var _y = new Vector3();
var _z = new Vector3();
function Matrix4() {
this.elements = [
1,
0,
0,
0,
0,
1,
0,
0,
0,
0,
1,
0,
0,
0,
0,
1
];
if (arguments.length > 0) {
console.error("THREE.Matrix4: the constructor no longer reads arguments. use .set() instead.");
}
}
Object.assign(Matrix4.prototype, {
isMatrix4: true,
set: function(n11, n12, n13, n14, n21, n22, n23, n24, n31, n32, n33, n34, n41, n42, n43, n44) {
var te = this.elements;
te[0] = n11;
te[4] = n12;
te[8] = n13;
te[12] = n14;
te[1] = n21;
te[5] = n22;
te[9] = n23;
te[13] = n24;
te[2] = n31;
te[6] = n32;
te[10] = n33;
te[14] = n34;
te[3] = n41;
te[7] = n42;
te[11] = n43;
te[15] = n44;
return this;
},
identity: function() {
this.set(
1,
0,
0,
0,
0,
1,
0,
0,
0,
0,
1,
0,
0,
0,
0,
1
);
return this;
},
clone: function() {
return new Matrix4().fromArray(this.elements);
},
copy: function(m) {
var te = this.elements;
var me = m.elements;
te[0] = me[0];
te[1] = me[1];
te[2] = me[2];
te[3] = me[3];
te[4] = me[4];
te[5] = me[5];
te[6] = me[6];
te[7] = me[7];
te[8] = me[8];
te[9] = me[9];
te[10] = me[10];
te[11] = me[11];
te[12] = me[12];
te[13] = me[13];
te[14] = me[14];
te[15] = me[15];
return this;
},
copyPosition: function(m) {
var te = this.elements, me = m.elements;
te[12] = me[12];
te[13] = me[13];
te[14] = me[14];
return this;
},
extractBasis: function(xAxis, yAxis, zAxis) {
xAxis.setFromMatrixColumn(this, 0);
yAxis.setFromMatrixColumn(this, 1);
zAxis.setFromMatrixColumn(this, 2);
return this;
},
makeBasis: function(xAxis, yAxis, zAxis) {
this.set(
xAxis.x,
yAxis.x,
zAxis.x,
0,
xAxis.y,
yAxis.y,
zAxis.y,
0,
xAxis.z,
yAxis.z,
zAxis.z,
0,
0,
0,
0,
1
);
return this;
},
extractRotation: function(m) {
var te = this.elements;
var me = m.elements;
var scaleX = 1 / _v1.setFromMatrixColumn(m, 0).length();
var scaleY = 1 / _v1.setFromMatrixColumn(m, 1).length();
var scaleZ = 1 / _v1.setFromMatrixColumn(m, 2).length();
te[0] = me[0] * scaleX;
te[1] = me[1] * scaleX;
te[2] = me[2] * scaleX;
te[3] = 0;
te[4] = me[4] * scaleY;
te[5] = me[5] * scaleY;
te[6] = me[6] * scaleY;
te[7] = 0;
te[8] = me[8] * scaleZ;
te[9] = me[9] * scaleZ;
te[10] = me[10] * scaleZ;
te[11] = 0;
te[12] = 0;
te[13] = 0;
te[14] = 0;
te[15] = 1;
return this;
},
makeRotationFromEuler: function(euler) {
if (!(euler && euler.isEuler)) {
console.error("THREE.Matrix4: .makeRotationFromEuler() now expects a Euler rotation rather than a Vector3 and order.");
}
var te = this.elements;
var x = euler.x, y = euler.y, z = euler.z;
var a = Math.cos(x), b = Math.sin(x);
var c = Math.cos(y), d = Math.sin(y);
var e = Math.cos(z), f = Math.sin(z);
if (euler.order === "XYZ") {
var ae = a * e, af = a * f, be = b * e, bf = b * f;
te[0] = c * e;
te[4] = -c * f;
te[8] = d;
te[1] = af + be * d;
te[5] = ae - bf * d;
te[9] = -b * c;
te[2] = bf - ae * d;
te[6] = be + af * d;
te[10] = a * c;
} else if (euler.order === "YXZ") {
var ce = c * e, cf = c * f, de = d * e, df = d * f;
te[0] = ce + df * b;
te[4] = de * b - cf;
te[8] = a * d;
te[1] = a * f;
te[5] = a * e;
te[9] = -b;
te[2] = cf * b - de;
te[6] = df + ce * b;
te[10] = a * c;
} else if (euler.order === "ZXY") {
var ce = c * e, cf = c * f, de = d * e, df = d * f;
te[0] = ce - df * b;
te[4] = -a * f;
te[8] = de + cf * b;
te[1] = cf + de * b;
te[5] = a * e;
te[9] = df - ce * b;
te[2] = -a * d;
te[6] = b;
te[10] = a * c;
} else if (euler.order === "ZYX") {
var ae = a * e, af = a * f, be = b * e, bf = b * f;
te[0] = c * e;
te[4] = be * d - af;
te[8] = ae * d + bf;
te[1] = c * f;
te[5] = bf * d + ae;
te[9] = af * d - be;
te[2] = -d;
te[6] = b * c;
te[10] = a * c;
} else if (euler.order === "YZX") {
var ac = a * c, ad = a * d, bc = b * c, bd = b * d;
te[0] = c * e;
te[4] = bd - ac * f;
te[8] = bc * f + ad;
te[1] = f;
te[5] = a * e;
te[9] = -b * e;
te[2] = -d * e;
te[6] = ad * f + bc;
te[10] = ac - bd * f;
} else if (euler.order === "XZY") {
var ac = a * c, ad = a * d, bc = b * c, bd = b * d;
te[0] = c * e;
te[4] = -f;
te[8] = d * e;
te[1] = ac * f + bd;
te[5] = a * e;
te[9] = ad * f - bc;
te[2] = bc * f - ad;
te[6] = b * e;
te[10] = bd * f + ac;
}
te[3] = 0;
te[7] = 0;
te[11] = 0;
te[12] = 0;
te[13] = 0;
te[14] = 0;
te[15] = 1;
return this;
},
makeRotationFromQuaternion: function(q) {
return this.compose(_zero, q, _one);
},
lookAt: function(eye, target, up) {
var te = this.elements;
_z.subVectors(eye, target);
if (_z.lengthSq() === 0) {
_z.z = 1;
}
_z.normalize();
_x.crossVectors(up, _z);
if (_x.lengthSq() === 0) {
if (Math.abs(up.z) === 1) {
_z.x += 1e-4;
} else {
_z.z += 1e-4;
}
_z.normalize();
_x.crossVectors(up, _z);
}
_x.normalize();
_y.crossVectors(_z, _x);
te[0] = _x.x;
te[4] = _y.x;
te[8] = _z.x;
te[1] = _x.y;
te[5] = _y.y;
te[9] = _z.y;
te[2] = _x.z;
te[6] = _y.z;
te[10] = _z.z;
return this;
},
multiply: function(m, n) {
if (n !== void 0) {
console.warn("THREE.Matrix4: .multiply() now only accepts one argument. Use .multiplyMatrices( a, b ) instead.");
return this.multiplyMatrices(m, n);
}
return this.multiplyMatrices(this, m);
},
premultiply: function(m) {
return this.multiplyMatrices(m, this);
},
multiplyMatrices: function(a, b) {
var ae = a.elements;
var be = b.elements;
var te = this.elements;
var a11 = ae[0], a12 = ae[4], a13 = ae[8], a14 = ae[12];
var a21 = ae[1], a22 = ae[5], a23 = ae[9], a24 = ae[13];
var a31 = ae[2], a32 = ae[6], a33 = ae[10], a34 = ae[14];
var a41 = ae[3], a42 = ae[7], a43 = ae[11], a44 = ae[15];
var b11 = be[0], b12 = be[4], b13 = be[8], b14 = be[12];
var b21 = be[1], b22 = be[5], b23 = be[9], b24 = be[13];
var b31 = be[2], b32 = be[6], b33 = be[10], b34 = be[14];
var b41 = be[3], b42 = be[7], b43 = be[11], b44 = be[15];
te[0] = a11 * b11 + a12 * b21 + a13 * b31 + a14 * b41;
te[4] = a11 * b12 + a12 * b22 + a13 * b32 + a14 * b42;
te[8] = a11 * b13 + a12 * b23 + a13 * b33 + a14 * b43;
te[12] = a11 * b14 + a12 * b24 + a13 * b34 + a14 * b44;
te[1] = a21 * b11 + a22 * b21 + a23 * b31 + a24 * b41;
te[5] = a21 * b12 + a22 * b22 + a23 * b32 + a24 * b42;
te[9] = a21 * b13 + a22 * b23 + a23 * b33 + a24 * b43;
te[13] = a21 * b14 + a22 * b24 + a23 * b34 + a24 * b44;
te[2] = a31 * b11 + a32 * b21 + a33 * b31 + a34 * b41;
te[6] = a31 * b12 + a32 * b22 + a33 * b32 + a34 * b42;
te[10] = a31 * b13 + a32 * b23 + a33 * b33 + a34 * b43;
te[14] = a31 * b14 + a32 * b24 + a33 * b34 + a34 * b44;
te[3] = a41 * b11 + a42 * b21 + a43 * b31 + a44 * b41;
te[7] = a41 * b12 + a42 * b22 + a43 * b32 + a44 * b42;
te[11] = a41 * b13 + a42 * b23 + a43 * b33 + a44 * b43;
te[15] = a41 * b14 + a42 * b24 + a43 * b34 + a44 * b44;
return this;
},
multiplyScalar: function(s) {
var te = this.elements;
te[0] *= s;
te[4] *= s;
te[8] *= s;
te[12] *= s;
te[1] *= s;
te[5] *= s;
te[9] *= s;
te[13] *= s;
te[2] *= s;
te[6] *= s;
te[10] *= s;
te[14] *= s;
te[3] *= s;
te[7] *= s;
te[11] *= s;
te[15] *= s;
return this;
},
determinant: function() {
var te = this.elements;
var n11 = te[0], n12 = te[4], n13 = te[8], n14 = te[12];
var n21 = te[1], n22 = te[5], n23 = te[9], n24 = te[13];
var n31 = te[2], n32 = te[6], n33 = te[10], n34 = te[14];
var n41 = te[3], n42 = te[7], n43 = te[11], n44 = te[15];
return n41 * (+n14 * n23 * n32 - n13 * n24 * n32 - n14 * n22 * n33 + n12 * n24 * n33 + n13 * n22 * n34 - n12 * n23 * n34) + n42 * (+n11 * n23 * n34 - n11 * n24 * n33 + n14 * n21 * n33 - n13 * n21 * n34 + n13 * n24 * n31 - n14 * n23 * n31) + n43 * (+n11 * n24 * n32 - n11 * n22 * n34 - n14 * n21 * n32 + n12 * n21 * n34 + n14 * n22 * n31 - n12 * n24 * n31) + n44 * (-n13 * n22 * n31 - n11 * n23 * n32 + n11 * n22 * n33 + n13 * n21 * n32 - n12 * n21 * n33 + n12 * n23 * n31);
},
transpose: function() {
var te = this.elements;
var tmp2;
tmp2 = te[1];
te[1] = te[4];
te[4] = tmp2;
tmp2 = te[2];
te[2] = te[8];
te[8] = tmp2;
tmp2 = te[6];
te[6] = te[9];
te[9] = tmp2;
tmp2 = te[3];
te[3] = te[12];
te[12] = tmp2;
tmp2 = te[7];
te[7] = te[13];
te[13] = tmp2;
tmp2 = te[11];
te[11] = te[14];
te[14] = tmp2;
return this;
},
setPosition: function(x, y, z) {
var te = this.elements;
if (x.isVector3) {
te[12] = x.x;
te[13] = x.y;
te[14] = x.z;
} else {
te[12] = x;
te[13] = y;
te[14] = z;
}
return this;
},
getInverse: function(m, throwOnDegenerate) {
var te = this.elements, me = m.elements, n11 = me[0], n21 = me[1], n31 = me[2], n41 = me[3], n12 = me[4], n22 = me[5], n32 = me[6], n42 = me[7], n13 = me[8], n23 = me[9], n33 = me[10], n43 = me[11], n14 = me[12], n24 = me[13], n34 = me[14], n44 = me[15], t11 = n23 * n34 * n42 - n24 * n33 * n42 + n24 * n32 * n43 - n22 * n34 * n43 - n23 * n32 * n44 + n22 * n33 * n44, t12 = n14 * n33 * n42 - n13 * n34 * n42 - n14 * n32 * n43 + n12 * n34 * n43 + n13 * n32 * n44 - n12 * n33 * n44, t13 = n13 * n24 * n42 - n14 * n23 * n42 + n14 * n22 * n43 - n12 * n24 * n43 - n13 * n22 * n44 + n12 * n23 * n44, t14 = n14 * n23 * n32 - n13 * n24 * n32 - n14 * n22 * n33 + n12 * n24 * n33 + n13 * n22 * n34 - n12 * n23 * n34;
var det = n11 * t11 + n21 * t12 + n31 * t13 + n41 * t14;
if (det === 0) {
var msg = "THREE.Matrix4: .getInverse() can't invert matrix, determinant is 0";
if (throwOnDegenerate === true) {
throw new Error(msg);
} else {
console.warn(msg);
}
return this.identity();
}
var detInv = 1 / det;
te[0] = t11 * detInv;
te[1] = (n24 * n33 * n41 - n23 * n34 * n41 - n24 * n31 * n43 + n21 * n34 * n43 + n23 * n31 * n44 - n21 * n33 * n44) * detInv;
te[2] = (n22 * n34 * n41 - n24 * n32 * n41 + n24 * n31 * n42 - n21 * n34 * n42 - n22 * n31 * n44 + n21 * n32 * n44) * detInv;
te[3] = (n23 * n32 * n41 - n22 * n33 * n41 - n23 * n31 * n42 + n21 * n33 * n42 + n22 * n31 * n43 - n21 * n32 * n43) * detInv;
te[4] = t12 * detInv;
te[5] = (n13 * n34 * n41 - n14 * n33 * n41 + n14 * n31 * n43 - n11 * n34 * n43 - n13 * n31 * n44 + n11 * n33 * n44) * detInv;
te[6] = (n14 * n32 * n41 - n12 * n34 * n41 - n14 * n31 * n42 + n11 * n34 * n42 + n12 * n31 * n44 - n11 * n32 * n44) * detInv;
te[7] = (n12 * n33 * n41 - n13 * n32 * n41 + n13 * n31 * n42 - n11 * n33 * n42 - n12 * n31 * n43 + n11 * n32 * n43) * detInv;
te[8] = t13 * detInv;
te[9] = (n14 * n23 * n41 - n13 * n24 * n41 - n14 * n21 * n43 + n11 * n24 * n43 + n13 * n21 * n44 - n11 * n23 * n44) * detInv;
te[10] = (n12 * n24 * n41 - n14 * n22 * n41 + n14 * n21 * n42 - n11 * n24 * n42 - n12 * n21 * n44 + n11 * n22 * n44) * detInv;
te[11] = (n13 * n22 * n41 - n12 * n23 * n41 - n13 * n21 * n42 + n11 * n23 * n42 + n12 * n21 * n43 - n11 * n22 * n43) * detInv;
te[12] = t14 * detInv;
te[13] = (n13 * n24 * n31 - n14 * n23 * n31 + n14 * n21 * n33 - n11 * n24 * n33 - n13 * n21 * n34 + n11 * n23 * n34) * detInv;
te[14] = (n14 * n22 * n31 - n12 * n24 * n31 - n14 * n21 * n32 + n11 * n24 * n32 + n12 * n21 * n34 - n11 * n22 * n34) * detInv;
te[15] = (n12 * n23 * n31 - n13 * n22 * n31 + n13 * n21 * n32 - n11 * n23 * n32 - n12 * n21 * n33 + n11 * n22 * n33) * detInv;
return this;
},
scale: function(v) {
var te = this.elements;
var x = v.x, y = v.y, z = v.z;
te[0] *= x;
te[4] *= y;
te[8] *= z;
te[1] *= x;
te[5] *= y;
te[9] *= z;
te[2] *= x;
te[6] *= y;
te[10] *= z;
te[3] *= x;
te[7] *= y;
te[11] *= z;
return this;
},
getMaxScaleOnAxis: function() {
var te = this.elements;
var scaleXSq = te[0] * te[0] + te[1] * te[1] + te[2] * te[2];
var scaleYSq = te[4] * te[4] + te[5] * te[5] + te[6] * te[6];
var scaleZSq = te[8] * te[8] + te[9] * te[9] + te[10] * te[10];
return Math.sqrt(Math.max(scaleXSq, scaleYSq, scaleZSq));
},
makeTranslation: function(x, y, z) {
this.set(
1,
0,
0,
x,
0,
1,
0,
y,
0,
0,
1,
z,
0,
0,
0,
1
);
return this;
},
makeRotationX: function(theta) {
var c = Math.cos(theta), s = Math.sin(theta);
this.set(
1,
0,
0,
0,
0,
c,
-s,
0,
0,
s,
c,
0,
0,
0,
0,
1
);
return this;
},
makeRotationY: function(theta) {
var c = Math.cos(theta), s = Math.sin(theta);
this.set(
c,
0,
s,
0,
0,
1,
0,
0,
-s,
0,
c,
0,
0,
0,
0,
1
);
return this;
},
makeRotationZ: function(theta) {
var c = Math.cos(theta), s = Math.sin(theta);
this.set(
c,
-s,
0,
0,
s,
c,
0,
0,
0,
0,
1,
0,
0,
0,
0,
1
);
return this;
},
makeRotationAxis: function(axis, angle) {
var c = Math.cos(angle);
var s = Math.sin(angle);
var t = 1 - c;
var x = axis.x, y = axis.y, z = axis.z;
var tx = t * x, ty = t * y;
this.set(
tx * x + c,
tx * y - s * z,
tx * z + s * y,
0,
tx * y + s * z,
ty * y + c,
ty * z - s * x,
0,
tx * z - s * y,
ty * z + s * x,
t * z * z + c,
0,
0,
0,
0,
1
);
return this;
},
makeScale: function(x, y, z) {
this.set(
x,
0,
0,
0,
0,
y,
0,
0,
0,
0,
z,
0,
0,
0,
0,
1
);
return this;
},
makeShear: function(x, y, z) {
this.set(
1,
y,
z,
0,
x,
1,
z,
0,
x,
y,
1,
0,
0,
0,
0,
1
);
return this;
},
compose: function(position, quaternion, scale) {
var te = this.elements;
var x = quaternion._x, y = quaternion._y, z = quaternion._z, w = quaternion._w;
var x2 = x + x, y2 = y + y, z2 = z + z;
var xx = x * x2, xy = x * y2, xz = x * z2;
var yy = y * y2, yz = y * z2, zz = z * z2;
var wx = w * x2, wy = w * y2, wz = w * z2;
var sx = scale.x, sy = scale.y, sz = scale.z;
te[0] = (1 - (yy + zz)) * sx;
te[1] = (xy + wz) * sx;
te[2] = (xz - wy) * sx;
te[3] = 0;
te[4] = (xy - wz) * sy;
te[5] = (1 - (xx + zz)) * sy;
te[6] = (yz + wx) * sy;
te[7] = 0;
te[8] = (xz + wy) * sz;
te[9] = (yz - wx) * sz;
te[10] = (1 - (xx + yy)) * sz;
te[11] = 0;
te[12] = position.x;
te[13] = position.y;
te[14] = position.z;
te[15] = 1;
return this;
},
decompose: function(position, quaternion, scale) {
var te = this.elements;
var sx = _v1.set(te[0], te[1], te[2]).length();
var sy = _v1.set(te[4], te[5], te[6]).length();
var sz = _v1.set(te[8], te[9], te[10]).length();
var det = this.determinant();
if (det < 0)
sx = -sx;
position.x = te[12];
position.y = te[13];
position.z = te[14];
_m1.copy(this);
var invSX = 1 / sx;
var invSY = 1 / sy;
var invSZ = 1 / sz;
_m1.elements[0] *= invSX;
_m1.elements[1] *= invSX;
_m1.elements[2] *= invSX;
_m1.elements[4] *= invSY;
_m1.elements[5] *= invSY;
_m1.elements[6] *= invSY;
_m1.elements[8] *= invSZ;
_m1.elements[9] *= invSZ;
_m1.elements[10] *= invSZ;
quaternion.setFromRotationMatrix(_m1);
scale.x = sx;
scale.y = sy;
scale.z = sz;
return this;
},
makePerspective: function(left, right, top2, bottom, near, far) {
if (far === void 0) {
console.warn("THREE.Matrix4: .makePerspective() has been redefined and has a new signature. Please check the docs.");
}
var te = this.elements;
var x = 2 * near / (right - left);
var y = 2 * near / (top2 - bottom);
var a = (right + left) / (right - left);
var b = (top2 + bottom) / (top2 - bottom);
var c = -(far + near) / (far - near);
var d = -2 * far * near / (far - near);
te[0] = x;
te[4] = 0;
te[8] = a;
te[12] = 0;
te[1] = 0;
te[5] = y;
te[9] = b;
te[13] = 0;
te[2] = 0;
te[6] = 0;
te[10] = c;
te[14] = d;
te[3] = 0;
te[7] = 0;
te[11] = -1;
te[15] = 0;
return this;
},
makeOrthographic: function(left, right, top2, bottom, near, far) {
var te = this.elements;
var w = 1 / (right - left);
var h = 1 / (top2 - bottom);
var p = 1 / (far - near);
var x = (right + left) * w;
var y = (top2 + bottom) * h;
var z = (far + near) * p;
te[0] = 2 * w;
te[4] = 0;
te[8] = 0;
te[12] = -x;
te[1] = 0;
te[5] = 2 * h;
te[9] = 0;
te[13] = -y;
te[2] = 0;
te[6] = 0;
te[10] = -2 * p;
te[14] = -z;
te[3] = 0;
te[7] = 0;
te[11] = 0;
te[15] = 1;
return this;
},
equals: function(matrix) {
var te = this.elements;
var me = matrix.elements;
for (var i2 = 0; i2 < 16; i2++) {
if (te[i2] !== me[i2])
return false;
}
return true;
},
fromArray: function(array, offset) {
if (offset === void 0)
offset = 0;
for (var i2 = 0; i2 < 16; i2++) {
this.elements[i2] = array[i2 + offset];
}
return this;
},
toArray: function(array, offset) {
if (array === void 0)
array = [];
if (offset === void 0)
offset = 0;
var te = this.elements;
array[offset] = te[0];
array[offset + 1] = te[1];
array[offset + 2] = te[2];
array[offset + 3] = te[3];
array[offset + 4] = te[4];
array[offset + 5] = te[5];
array[offset + 6] = te[6];
array[offset + 7] = te[7];
array[offset + 8] = te[8];
array[offset + 9] = te[9];
array[offset + 10] = te[10];
array[offset + 11] = te[11];
array[offset + 12] = te[12];
array[offset + 13] = te[13];
array[offset + 14] = te[14];
array[offset + 15] = te[15];
return array;
}
});
var _matrix = new Matrix4();
var _quaternion$1 = new Quaternion();
function Euler(x, y, z, order) {
this._x = x || 0;
this._y = y || 0;
this._z = z || 0;
this._order = order || Euler.DefaultOrder;
}
Euler.RotationOrders = ["XYZ", "YZX", "ZXY", "XZY", "YXZ", "ZYX"];
Euler.DefaultOrder = "XYZ";
Object.defineProperties(Euler.prototype, {
x: {
get: function() {
return this._x;
},
set: function(value) {
this._x = value;
this._onChangeCallback();
}
},
y: {
get: function() {
return this._y;
},
set: function(value) {
this._y = value;
this._onChangeCallback();
}
},
z: {
get: function() {
return this._z;
},
set: function(value) {
this._z = value;
this._onChangeCallback();
}
},
order: {
get: function() {
return this._order;
},
set: function(value) {
this._order = value;
this._onChangeCallback();
}
}
});
Object.assign(Euler.prototype, {
isEuler: true,
set: function(x, y, z, order) {
this._x = x;
this._y = y;
this._z = z;
this._order = order || this._order;
this._onChangeCallback();
return this;
},
clone: function() {
return new this.constructor(this._x, this._y, this._z, this._order);
},
copy: function(euler) {
this._x = euler._x;
this._y = euler._y;
this._z = euler._z;
this._order = euler._order;
this._onChangeCallback();
return this;
},
setFromRotationMatrix: function(m, order, update) {
var clamp = MathUtils.clamp;
var te = m.elements;
var m11 = te[0], m12 = te[4], m13 = te[8];
var m21 = te[1], m22 = te[5], m23 = te[9];
var m31 = te[2], m32 = te[6], m33 = te[10];
order = order || this._order;
if (order === "XYZ") {
this._y = Math.asin(clamp(m13, -1, 1));
if (Math.abs(m13) < 0.9999999) {
this._x = Math.atan2(-m23, m33);
this._z = Math.atan2(-m12, m11);
} else {
this._x = Math.atan2(m32, m22);
this._z = 0;
}
} else if (order === "YXZ") {
this._x = Math.asin(-clamp(m23, -1, 1));
if (Math.abs(m23) < 0.9999999) {
this._y = Math.atan2(m13, m33);
this._z = Math.atan2(m21, m22);
} else {
this._y = Math.atan2(-m31, m11);
this._z = 0;
}
} else if (order === "ZXY") {
this._x = Math.asin(clamp(m32, -1, 1));
if (Math.abs(m32) < 0.9999999) {
this._y = Math.atan2(-m31, m33);
this._z = Math.atan2(-m12, m22);
} else {
this._y = 0;
this._z = Math.atan2(m21, m11);
}
} else if (order === "ZYX") {
this._y = Math.asin(-clamp(m31, -1, 1));
if (Math.abs(m31) < 0.9999999) {
this._x = Math.atan2(m32, m33);
this._z = Math.atan2(m21, m11);
} else {
this._x = 0;
this._z = Math.atan2(-m12, m22);
}
} else if (order === "YZX") {
this._z = Math.asin(clamp(m21, -1, 1));
if (Math.abs(m21) < 0.9999999) {
this._x = Math.atan2(-m23, m22);
this._y = Math.atan2(-m31, m11);
} else {
this._x = 0;
this._y = Math.atan2(m13, m33);
}
} else if (order === "XZY") {
this._z = Math.asin(-clamp(m12, -1, 1));
if (Math.abs(m12) < 0.9999999) {
this._x = Math.atan2(m32, m22);
this._y = Math.atan2(m13, m11);
} else {
this._x = Math.atan2(-m23, m33);
this._y = 0;
}
} else {
console.warn("THREE.Euler: .setFromRotationMatrix() given unsupported order: " + order);
}
this._order = order;
if (update !== false)
this._onChangeCallback();
return this;
},
setFromQuaternion: function(q, order, update) {
_matrix.makeRotationFromQuaternion(q);
return this.setFromRotationMatrix(_matrix, order, update);
},
setFromVector3: function(v, order) {
return this.set(v.x, v.y, v.z, order || this._order);
},
reorder: function(newOrder) {
_quaternion$1.setFromEuler(this);
return this.setFromQuaternion(_quaternion$1, newOrder);
},
equals: function(euler) {
return euler._x === this._x && euler._y === this._y && euler._z === this._z && euler._order === this._order;
},
fromArray: function(array) {
this._x = array[0];
this._y = array[1];
this._z = array[2];
if (array[3] !== void 0)
this._order = array[3];
this._onChangeCallback();
return this;
},
toArray: function(array, offset) {
if (array === void 0)
array = [];
if (offset === void 0)
offset = 0;
array[offset] = this._x;
array[offset + 1] = this._y;
array[offset + 2] = this._z;
array[offset + 3] = this._order;
return array;
},
toVector3: function(optionalResult) {
if (optionalResult) {
return optionalResult.set(this._x, this._y, this._z);
} else {
return new Vector3(this._x, this._y, this._z);
}
},
_onChange: function(callback) {
this._onChangeCallback = callback;
return this;
},
_onChangeCallback: function() {
}
});
function Layers() {
this.mask = 1 | 0;
}
Object.assign(Layers.prototype, {
set: function(channel) {
this.mask = 1 << channel | 0;
},
enable: function(channel) {
this.mask |= 1 << channel | 0;
},
enableAll: function() {
this.mask = 4294967295 | 0;
},
toggle: function(channel) {
this.mask ^= 1 << channel | 0;
},
disable: function(channel) {
this.mask &= ~(1 << channel | 0);
},
disableAll: function() {
this.mask = 0;
},
test: function(layers) {
return (this.mask & layers.mask) !== 0;
}
});
var _object3DId = 0;
var _v1$1 = new Vector3();
var _q1 = new Quaternion();
var _m1$1 = new Matrix4();
var _target = new Vector3();
var _position = new Vector3();
var _scale = new Vector3();
var _quaternion$2 = new Quaternion();
var _xAxis = new Vector3(1, 0, 0);
var _yAxis = new Vector3(0, 1, 0);
var _zAxis = new Vector3(0, 0, 1);
var _addedEvent = { type: "added" };
var _removedEvent = { type: "removed" };
function Object3D() {
Object.defineProperty(this, "id", { value: _object3DId++ });
this.uuid = MathUtils.generateUUID();
this.name = "";
this.type = "Object3D";
this.parent = null;
this.children = [];
this.up = Object3D.DefaultUp.clone();
var position = new Vector3();
var rotation = new Euler();
var quaternion = new Quaternion();
var scale = new Vector3(1, 1, 1);
function onRotationChange() {
quaternion.setFromEuler(rotation, false);
}
function onQuaternionChange() {
rotation.setFromQuaternion(quaternion, void 0, false);
}
rotation._onChange(onRotationChange);
quaternion._onChange(onQuaternionChange);
Object.defineProperties(this, {
position: {
configurable: true,
enumerable: true,
value: position
},
rotation: {
configurable: true,
enumerable: true,
value: rotation
},
quaternion: {
configurable: true,
enumerable: true,
value: quaternion
},
scale: {
configurable: true,
enumerable: true,
value: scale
},
modelViewMatrix: {
value: new Matrix4()
},
normalMatrix: {
value: new Matrix3()
}
});
this.matrix = new Matrix4();
this.matrixWorld = new Matrix4();
this.matrixAutoUpdate = Object3D.DefaultMatrixAutoUpdate;
this.matrixWorldNeedsUpdate = false;
this.layers = new Layers();
this.visible = true;
this.castShadow = false;
this.receiveShadow = false;
this.frustumCulled = true;
this.renderOrder = 0;
this.userData = {};
}
Object3D.DefaultUp = new Vector3(0, 1, 0);
Object3D.DefaultMatrixAutoUpdate = true;
Object3D.prototype = Object.assign(Object.create(EventDispatcher.prototype), {
constructor: Object3D,
isObject3D: true,
onBeforeRender: function() {
},
onAfterRender: function() {
},
applyMatrix4: function(matrix) {
if (this.matrixAutoUpdate)
this.updateMatrix();
this.matrix.premultiply(matrix);
this.matrix.decompose(this.position, this.quaternion, this.scale);
},
applyQuaternion: function(q) {
this.quaternion.premultiply(q);
return this;
},
setRotationFromAxisAngle: function(axis, angle) {
this.quaternion.setFromAxisAngle(axis, angle);
},
setRotationFromEuler: function(euler) {
this.quaternion.setFromEuler(euler, true);
},
setRotationFromMatrix: function(m) {
this.quaternion.setFromRotationMatrix(m);
},
setRotationFromQuaternion: function(q) {
this.quaternion.copy(q);
},
rotateOnAxis: function(axis, angle) {
_q1.setFromAxisAngle(axis, angle);
this.quaternion.multiply(_q1);
return this;
},
rotateOnWorldAxis: function(axis, angle) {
_q1.setFromAxisAngle(axis, angle);
this.quaternion.premultiply(_q1);
return this;
},
rotateX: function(angle) {
return this.rotateOnAxis(_xAxis, angle);
},
rotateY: function(angle) {
return this.rotateOnAxis(_yAxis, angle);
},
rotateZ: function(angle) {
return this.rotateOnAxis(_zAxis, angle);
},
translateOnAxis: function(axis, distance) {
_v1$1.copy(axis).applyQuaternion(this.quaternion);
this.position.add(_v1$1.multiplyScalar(distance));
return this;
},
translateX: function(distance) {
return this.translateOnAxis(_xAxis, distance);
},
translateY: function(distance) {
return this.translateOnAxis(_yAxis, distance);
},
translateZ: function(distance) {
return this.translateOnAxis(_zAxis, distance);
},
localToWorld: function(vector) {
return vector.applyMatrix4(this.matrixWorld);
},
worldToLocal: function(vector) {
return vector.applyMatrix4(_m1$1.getInverse(this.matrixWorld));
},
lookAt: function(x, y, z) {
if (x.isVector3) {
_target.copy(x);
} else {
_target.set(x, y, z);
}
var parent = this.parent;
this.updateWorldMatrix(true, false);
_position.setFromMatrixPosition(this.matrixWorld);
if (this.isCamera || this.isLight) {
_m1$1.lookAt(_position, _target, this.up);
} else {
_m1$1.lookAt(_target, _position, this.up);
}
this.quaternion.setFromRotationMatrix(_m1$1);
if (parent) {
_m1$1.extractRotation(parent.matrixWorld);
_q1.setFromRotationMatrix(_m1$1);
this.quaternion.premultiply(_q1.inverse());
}
},
add: function(object) {
if (arguments.length > 1) {
for (var i2 = 0; i2 < arguments.length; i2++) {
this.add(arguments[i2]);
}
return this;
}
if (object === this) {
console.error("THREE.Object3D.add: object can't be added as a child of itself.", object);
return this;
}
if (object && object.isObject3D) {
if (object.parent !== null) {
object.parent.remove(object);
}
object.parent = this;
this.children.push(object);
object.dispatchEvent(_addedEvent);
} else {
console.error("THREE.Object3D.add: object not an instance of THREE.Object3D.", object);
}
return this;
},
remove: function(object) {
if (arguments.length > 1) {
for (var i2 = 0; i2 < arguments.length; i2++) {
this.remove(arguments[i2]);
}
return this;
}
var index = this.children.indexOf(object);
if (index !== -1) {
object.parent = null;
this.children.splice(index, 1);
object.dispatchEvent(_removedEvent);
}
return this;
},
attach: function(object) {
this.updateWorldMatrix(true, false);
_m1$1.getInverse(this.matrixWorld);
if (object.parent !== null) {
object.parent.updateWorldMatrix(true, false);
_m1$1.multiply(object.parent.matrixWorld);
}
object.applyMatrix4(_m1$1);
object.updateWorldMatrix(false, false);
this.add(object);
return this;
},
getObjectById: function(id) {
return this.getObjectByProperty("id", id);
},
getObjectByName: function(name) {
return this.getObjectByProperty("name", name);
},
getObjectByProperty: function(name, value) {
if (this[name] === value)
return this;
for (var i2 = 0, l = this.children.length; i2 < l; i2++) {
var child = this.children[i2];
var object = child.getObjectByProperty(name, value);
if (object !== void 0) {
return object;
}
}
return void 0;
},
getWorldPosition: function(target) {
if (target === void 0) {
console.warn("THREE.Object3D: .getWorldPosition() target is now required");
target = new Vector3();
}
this.updateMatrixWorld(true);
return target.setFromMatrixPosition(this.matrixWorld);
},
getWorldQuaternion: function(target) {
if (target === void 0) {
console.warn("THREE.Object3D: .getWorldQuaternion() target is now required");
target = new Quaternion();
}
this.updateMatrixWorld(true);
this.matrixWorld.decompose(_position, target, _scale);
return target;
},
getWorldScale: function(target) {
if (target === void 0) {
console.warn("THREE.Object3D: .getWorldScale() target is now required");
target = new Vector3();
}
this.updateMatrixWorld(true);
this.matrixWorld.decompose(_position, _quaternion$2, target);
return target;
},
getWorldDirection: function(target) {
if (target === void 0) {
console.warn("THREE.Object3D: .getWorldDirection() target is now required");
target = new Vector3();
}
this.updateMatrixWorld(true);
var e = this.matrixWorld.elements;
return target.set(e[8], e[9], e[10]).normalize();
},
raycast: function() {
},
traverse: function(callback) {
callback(this);
var children = this.children;
for (var i2 = 0, l = children.length; i2 < l; i2++) {
children[i2].traverse(callback);
}
},
traverseVisible: function(callback) {
if (this.visible === false)
return;
callback(this);
var children = this.children;
for (var i2 = 0, l = children.length; i2 < l; i2++) {
children[i2].traverseVisible(callback);
}
},
traverseAncestors: function(callback) {
var parent = this.parent;
if (parent !== null) {
callback(parent);
parent.traverseAncestors(callback);
}
},
updateMatrix: function() {
this.matrix.compose(this.position, this.quaternion, this.scale);
this.matrixWorldNeedsUpdate = true;
},
updateMatrixWorld: function(force) {
if (this.matrixAutoUpdate)
this.updateMatrix();
if (this.matrixWorldNeedsUpdate || force) {
if (this.parent === null) {
this.matrixWorld.copy(this.matrix);
} else {
this.matrixWorld.multiplyMatrices(this.parent.matrixWorld, this.matrix);
}
this.matrixWorldNeedsUpdate = false;
force = true;
}
var children = this.children;
for (var i2 = 0, l = children.length; i2 < l; i2++) {
children[i2].updateMatrixWorld(force);
}
},
updateWorldMatrix: function(updateParents, updateChildren) {
var parent = this.parent;
if (updateParents === true && parent !== null) {
parent.updateWorldMatrix(true, false);
}
if (this.matrixAutoUpdate)
this.updateMatrix();
if (this.parent === null) {
this.matrixWorld.copy(this.matrix);
} else {
this.matrixWorld.multiplyMatrices(this.parent.matrixWorld, this.matrix);
}
if (updateChildren === true) {
var children = this.children;
for (var i2 = 0, l = children.length; i2 < l; i2++) {
children[i2].updateWorldMatrix(false, true);
}
}
},
toJSON: function(meta) {
var isRootObject = meta === void 0 || typeof meta === "string";
var output = {};
if (isRootObject) {
meta = {
geometries: {},
materials: {},
textures: {},
images: {},
shapes: {}
};
output.metadata = {
version: 4.5,
type: "Object",
generator: "Object3D.toJSON"
};
}
var object = {};
object.uuid = this.uuid;
object.type = this.type;
if (this.name !== "")
object.name = this.name;
if (this.castShadow === true)
object.castShadow = true;
if (this.receiveShadow === true)
object.receiveShadow = true;
if (this.visible === false)
object.visible = false;
if (this.frustumCulled === false)
object.frustumCulled = false;
if (this.renderOrder !== 0)
object.renderOrder = this.renderOrder;
if (JSON.stringify(this.userData) !== "{}")
object.userData = this.userData;
object.layers = this.layers.mask;
object.matrix = this.matrix.toArray();
if (this.matrixAutoUpdate === false)
object.matrixAutoUpdate = false;
if (this.isInstancedMesh) {
object.type = "InstancedMesh";
object.count = this.count;
object.instanceMatrix = this.instanceMatrix.toJSON();
}
function serialize(library, element) {
if (library[element.uuid] === void 0) {
library[element.uuid] = element.toJSON(meta);
}
return element.uuid;
}
if (this.isMesh || this.isLine || this.isPoints) {
object.geometry = serialize(meta.geometries, this.geometry);
var parameters = this.geometry.parameters;
if (parameters !== void 0 && parameters.shapes !== void 0) {
var shapes = parameters.shapes;
if (Array.isArray(shapes)) {
for (var i2 = 0, l = shapes.length; i2 < l; i2++) {
var shape = shapes[i2];
serialize(meta.shapes, shape);
}
} else {
serialize(meta.shapes, shapes);
}
}
}
if (this.material !== void 0) {
if (Array.isArray(this.material)) {
var uuids = [];
for (var i2 = 0, l = this.material.length; i2 < l; i2++) {
uuids.push(serialize(meta.materials, this.material[i2]));
}
object.material = uuids;
} else {
object.material = serialize(meta.materials, this.material);
}
}
if (this.children.length > 0) {
object.children = [];
for (var i2 = 0; i2 < this.children.length; i2++) {
object.children.push(this.children[i2].toJSON(meta).object);
}
}
if (isRootObject) {
var geometries = extractFromCache(meta.geometries);
var materials = extractFromCache(meta.materials);
var textures = extractFromCache(meta.textures);
var images = extractFromCache(meta.images);
var shapes = extractFromCache(meta.shapes);
if (geometries.length > 0)
output.geometries = geometries;
if (materials.length > 0)
output.materials = materials;
if (textures.length > 0)
output.textures = textures;
if (images.length > 0)
output.images = images;
if (shapes.length > 0)
output.shapes = shapes;
}
output.object = object;
return output;
function extractFromCache(cache) {
var values = [];
for (var key in cache) {
var data = cache[key];
delete data.metadata;
values.push(data);
}
return values;
}
},
clone: function(recursive) {
return new this.constructor().copy(this, recursive);
},
copy: function(source, recursive) {
if (recursive === void 0)
recursive = true;
this.name = source.name;
this.up.copy(source.up);
this.position.copy(source.position);
this.quaternion.copy(source.quaternion);
this.scale.copy(source.scale);
this.matrix.copy(source.matrix);
this.matrixWorld.copy(source.matrixWorld);
this.matrixAutoUpdate = source.matrixAutoUpdate;
this.matrixWorldNeedsUpdate = source.matrixWorldNeedsUpdate;
this.layers.mask = source.layers.mask;
this.visible = source.visible;
this.castShadow = source.castShadow;
this.receiveShadow = source.receiveShadow;
this.frustumCulled = source.frustumCulled;
this.renderOrder = source.renderOrder;
this.userData = JSON.parse(JSON.stringify(source.userData));
if (recursive === true) {
for (var i2 = 0; i2 < source.children.length; i2++) {
var child = source.children[i2];
this.add(child.clone());
}
}
return this;
}
});
function Scene() {
Object3D.call(this);
this.type = "Scene";
this.background = null;
this.environment = null;
this.fog = null;
this.overrideMaterial = null;
this.autoUpdate = true;
if (typeof __THREE_DEVTOOLS__ !== "undefined") {
__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe", { detail: this }));
}
}
Scene.prototype = Object.assign(Object.create(Object3D.prototype), {
constructor: Scene,
isScene: true,
copy: function(source, recursive) {
Object3D.prototype.copy.call(this, source, recursive);
if (source.background !== null)
this.background = source.background.clone();
if (source.environment !== null)
this.environment = source.environment.clone();
if (source.fog !== null)
this.fog = source.fog.clone();
if (source.overrideMaterial !== null)
this.overrideMaterial = source.overrideMaterial.clone();
this.autoUpdate = source.autoUpdate;
this.matrixAutoUpdate = source.matrixAutoUpdate;
return this;
},
toJSON: function(meta) {
var data = Object3D.prototype.toJSON.call(this, meta);
if (this.background !== null)
data.object.background = this.background.toJSON(meta);
if (this.environment !== null)
data.object.environment = this.environment.toJSON(meta);
if (this.fog !== null)
data.object.fog = this.fog.toJSON();
return data;
},
dispose: function() {
this.dispatchEvent({ type: "dispose" });
}
});
var _points = [
new Vector3(),
new Vector3(),
new Vector3(),
new Vector3(),
new Vector3(),
new Vector3(),
new Vector3(),
new Vector3()
];
var _vector$1 = new Vector3();
var _box = new Box3();
var _v0 = new Vector3();
var _v1$2 = new Vector3();
var _v2 = new Vector3();
var _f0 = new Vector3();
var _f1 = new Vector3();
var _f2 = new Vector3();
var _center = new Vector3();
var _extents = new Vector3();
var _triangleNormal = new Vector3();
var _testAxis = new Vector3();
function Box3(min, max) {
this.min = min !== void 0 ? min : new Vector3(Infinity, Infinity, Infinity);
this.max = max !== void 0 ? max : new Vector3(-Infinity, -Infinity, -Infinity);
}
Object.assign(Box3.prototype, {
isBox3: true,
set: function(min, max) {
this.min.copy(min);
this.max.copy(max);
return this;
},
setFromArray: function(array) {
var minX = Infinity;
var minY = Infinity;
var minZ = Infinity;
var maxX = -Infinity;
var maxY = -Infinity;
var maxZ = -Infinity;
for (var i2 = 0, l = array.length; i2 < l; i2 += 3) {
var x = array[i2];
var y = array[i2 + 1];
var z = array[i2 + 2];
if (x < minX)
minX = x;
if (y < minY)
minY = y;
if (z < minZ)
minZ = z;
if (x > maxX)
maxX = x;
if (y > maxY)
maxY = y;
if (z > maxZ)
maxZ = z;
}
this.min.set(minX, minY, minZ);
this.max.set(maxX, maxY, maxZ);
return this;
},
setFromBufferAttribute: function(attribute) {
var minX = Infinity;
var minY = Infinity;
var minZ = Infinity;
var maxX = -Infinity;
var maxY = -Infinity;
var maxZ = -Infinity;
for (var i2 = 0, l = attribute.count; i2 < l; i2++) {
var x = attribute.getX(i2);
var y = attribute.getY(i2);
var z = attribute.getZ(i2);
if (x < minX)
minX = x;
if (y < minY)
minY = y;
if (z < minZ)
minZ = z;
if (x > maxX)
maxX = x;
if (y > maxY)
maxY = y;
if (z > maxZ)
maxZ = z;
}
this.min.set(minX, minY, minZ);
this.max.set(maxX, maxY, maxZ);
return this;
},
setFromPoints: function(points) {
this.makeEmpty();
for (var i2 = 0, il = points.length; i2 < il; i2++) {
this.expandByPoint(points[i2]);
}
return this;
},
setFromCenterAndSize: function(center, size) {
var halfSize = _vector$1.copy(size).multiplyScalar(0.5);
this.min.copy(center).sub(halfSize);
this.max.copy(center).add(halfSize);
return this;
},
setFromObject: function(object) {
this.makeEmpty();
return this.expandByObject(object);
},
clone: function() {
return new this.constructor().copy(this);
},
copy: function(box) {
this.min.copy(box.min);
this.max.copy(box.max);
return this;
},
makeEmpty: function() {
this.min.x = this.min.y = this.min.z = Infinity;
this.max.x = this.max.y = this.max.z = -Infinity;
return this;
},
isEmpty: function() {
return this.max.x < this.min.x || this.max.y < this.min.y || this.max.z < this.min.z;
},
getCenter: function(target) {
if (target === void 0) {
console.warn("THREE.Box3: .getCenter() target is now required");
target = new Vector3();
}
return this.isEmpty() ? target.set(0, 0, 0) : target.addVectors(this.min, this.max).multiplyScalar(0.5);
},
getSize: function(target) {
if (target === void 0) {
console.warn("THREE.Box3: .getSize() target is now required");
target = new Vector3();
}
return this.isEmpty() ? target.set(0, 0, 0) : target.subVectors(this.max, this.min);
},
expandByPoint: function(point) {
this.min.min(point);
this.max.max(point);
return this;
},
expandByVector: function(vector) {
this.min.sub(vector);
this.max.add(vector);
return this;
},
expandByScalar: function(scalar) {
this.min.addScalar(-scalar);
this.max.addScalar(scalar);
return this;
},
expandByObject: function(object) {
object.updateWorldMatrix(false, false);
var geometry = object.geometry;
if (geometry !== void 0) {
if (geometry.boundingBox === null) {
geometry.computeBoundingBox();
}
_box.copy(geometry.boundingBox);
_box.applyMatrix4(object.matrixWorld);
this.expandByPoint(_box.min);
this.expandByPoint(_box.max);
}
var children = object.children;
for (var i2 = 0, l = children.length; i2 < l; i2++) {
this.expandByObject(children[i2]);
}
return this;
},
containsPoint: function(point) {
return point.x < this.min.x || point.x > this.max.x || point.y < this.min.y || point.y > this.max.y || point.z < this.min.z || point.z > this.max.z ? false : true;
},
containsBox: function(box) {
return this.min.x <= box.min.x && box.max.x <= this.max.x && this.min.y <= box.min.y && box.max.y <= this.max.y && this.min.z <= box.min.z && box.max.z <= this.max.z;
},
getParameter: function(point, target) {
if (target === void 0) {
console.warn("THREE.Box3: .getParameter() target is now required");
target = new Vector3();
}
return target.set(
(point.x - this.min.x) / (this.max.x - this.min.x),
(point.y - this.min.y) / (this.max.y - this.min.y),
(point.z - this.min.z) / (this.max.z - this.min.z)
);
},
intersectsBox: function(box) {
return box.max.x < this.min.x || box.min.x > this.max.x || box.max.y < this.min.y || box.min.y > this.max.y || box.max.z < this.min.z || box.min.z > this.max.z ? false : true;
},
intersectsSphere: function(sphere) {
this.clampPoint(sphere.center, _vector$1);
return _vector$1.distanceToSquared(sphere.center) <= sphere.radius * sphere.radius;
},
intersectsPlane: function(plane) {
var min, max;
if (plane.normal.x > 0) {
min = plane.normal.x * this.min.x;
max = plane.normal.x * this.max.x;
} else {
min = plane.normal.x * this.max.x;
max = plane.normal.x * this.min.x;
}
if (plane.normal.y > 0) {
min += plane.normal.y * this.min.y;
max += plane.normal.y * this.max.y;
} else {
min += plane.normal.y * this.max.y;
max += plane.normal.y * this.min.y;
}
if (plane.normal.z > 0) {
min += plane.normal.z * this.min.z;
max += plane.normal.z * this.max.z;
} else {
min += plane.normal.z * this.max.z;
max += plane.normal.z * this.min.z;
}
return min <= -plane.constant && max >= -plane.constant;
},
intersectsTriangle: function(triangle) {
if (this.isEmpty()) {
return false;
}
this.getCenter(_center);
_extents.subVectors(this.max, _center);
_v0.subVectors(triangle.a, _center);
_v1$2.subVectors(triangle.b, _center);
_v2.subVectors(triangle.c, _center);
_f0.subVectors(_v1$2, _v0);
_f1.subVectors(_v2, _v1$2);
_f2.subVectors(_v0, _v2);
var axes = [
0,
-_f0.z,
_f0.y,
0,
-_f1.z,
_f1.y,
0,
-_f2.z,
_f2.y,
_f0.z,
0,
-_f0.x,
_f1.z,
0,
-_f1.x,
_f2.z,
0,
-_f2.x,
-_f0.y,
_f0.x,
0,
-_f1.y,
_f1.x,
0,
-_f2.y,
_f2.x,
0
];
if (!satForAxes(axes, _v0, _v1$2, _v2, _extents)) {
return false;
}
axes = [1, 0, 0, 0, 1, 0, 0, 0, 1];
if (!satForAxes(axes, _v0, _v1$2, _v2, _extents)) {
return false;
}
_triangleNormal.crossVectors(_f0, _f1);
axes = [_triangleNormal.x, _triangleNormal.y, _triangleNormal.z];
return satForAxes(axes, _v0, _v1$2, _v2, _extents);
},
clampPoint: function(point, target) {
if (target === void 0) {
console.warn("THREE.Box3: .clampPoint() target is now required");
target = new Vector3();
}
return target.copy(point).clamp(this.min, this.max);
},
distanceToPoint: function(point) {
var clampedPoint = _vector$1.copy(point).clamp(this.min, this.max);
return clampedPoint.sub(point).length();
},
getBoundingSphere: function(target) {
if (target === void 0) {
console.error("THREE.Box3: .getBoundingSphere() target is now required");
}
this.getCenter(target.center);
target.radius = this.getSize(_vector$1).length() * 0.5;
return target;
},
intersect: function(box) {
this.min.max(box.min);
this.max.min(box.max);
if (this.isEmpty())
this.makeEmpty();
return this;
},
union: function(box) {
this.min.min(box.min);
this.max.max(box.max);
return this;
},
applyMatrix4: function(matrix) {
if (this.isEmpty())
return this;
_points[0].set(this.min.x, this.min.y, this.min.z).applyMatrix4(matrix);
_points[1].set(this.min.x, this.min.y, this.max.z).applyMatrix4(matrix);
_points[2].set(this.min.x, this.max.y, this.min.z).applyMatrix4(matrix);
_points[3].set(this.min.x, this.max.y, this.max.z).applyMatrix4(matrix);
_points[4].set(this.max.x, this.min.y, this.min.z).applyMatrix4(matrix);
_points[5].set(this.max.x, this.min.y, this.max.z).applyMatrix4(matrix);
_points[6].set(this.max.x, this.max.y, this.min.z).applyMatrix4(matrix);
_points[7].set(this.max.x, this.max.y, this.max.z).applyMatrix4(matrix);
this.setFromPoints(_points);
return this;
},
translate: function(offset) {
this.min.add(offset);
this.max.add(offset);
return this;
},
equals: function(box) {
return box.min.equals(this.min) && box.max.equals(this.max);
}
});
function satForAxes(axes, v0, v1, v2, extents) {
var i2, j;
for (i2 = 0, j = axes.length - 3; i2 <= j; i2 += 3) {
_testAxis.fromArray(axes, i2);
var r = extents.x * Math.abs(_testAxis.x) + extents.y * Math.abs(_testAxis.y) + extents.z * Math.abs(_testAxis.z);
var p0 = v0.dot(_testAxis);
var p1 = v1.dot(_testAxis);
var p2 = v2.dot(_testAxis);
if (Math.max(-Math.max(p0, p1, p2), Math.min(p0, p1, p2)) > r) {
return false;
}
}
return true;
}
var _box$1 = new Box3();
function Sphere(center, radius) {
this.center = center !== void 0 ? center : new Vector3();
this.radius = radius !== void 0 ? radius : 0;
}
Object.assign(Sphere.prototype, {
set: function(center, radius) {
this.center.copy(center);
this.radius = radius;
return this;
},
setFromPoints: function(points, optionalCenter) {
var center = this.center;
if (optionalCenter !== void 0) {
center.copy(optionalCenter);
} else {
_box$1.setFromPoints(points).getCenter(center);
}
var maxRadiusSq = 0;
for (var i2 = 0, il = points.length; i2 < il; i2++) {
maxRadiusSq = Math.max(maxRadiusSq, center.distanceToSquared(points[i2]));
}
this.radius = Math.sqrt(maxRadiusSq);
return this;
},
clone: function() {
return new this.constructor().copy(this);
},
copy: function(sphere) {
this.center.copy(sphere.center);
this.radius = sphere.radius;
return this;
},
empty: function() {
return this.radius <= 0;
},
containsPoint: function(point) {
return point.distanceToSquared(this.center) <= this.radius * this.radius;
},
distanceToPoint: function(point) {
return point.distanceTo(this.center) - this.radius;
},
intersectsSphere: function(sphere) {
var radiusSum = this.radius + sphere.radius;
return sphere.center.distanceToSquared(this.center) <= radiusSum * radiusSum;
},
intersectsBox: function(box) {
return box.intersectsSphere(this);
},
intersectsPlane: function(plane) {
return Math.abs(plane.distanceToPoint(this.center)) <= this.radius;
},
clampPoint: function(point, target) {
var deltaLengthSq = this.center.distanceToSquared(point);
if (target === void 0) {
console.warn("THREE.Sphere: .clampPoint() target is now required");
target = new Vector3();
}
target.copy(point);
if (deltaLengthSq > this.radius * this.radius) {
target.sub(this.center).normalize();
target.multiplyScalar(this.radius).add(this.center);
}
return target;
},
getBoundingBox: function(target) {
if (target === void 0) {
console.warn("THREE.Sphere: .getBoundingBox() target is now required");
target = new Box3();
}
target.set(this.center, this.center);
target.expandByScalar(this.radius);
return target;
},
applyMatrix4: function(matrix) {
this.center.applyMatrix4(matrix);
this.radius = this.radius * matrix.getMaxScaleOnAxis();
return this;
},
translate: function(offset) {
this.center.add(offset);
return this;
},
equals: function(sphere) {
return sphere.center.equals(this.center) && sphere.radius === this.radius;
}
});
var _vector$2 = new Vector3();
var _segCenter = new Vector3();
var _segDir = new Vector3();
var _diff = new Vector3();
var _edge1 = new Vector3();
var _edge2 = new Vector3();
var _normal = new Vector3();
function Ray(origin, direction) {
this.origin = origin !== void 0 ? origin : new Vector3();
this.direction = direction !== void 0 ? direction : new Vector3(0, 0, -1);
}
Object.assign(Ray.prototype, {
set: function(origin, direction) {
this.origin.copy(origin);
this.direction.copy(direction);
return this;
},
clone: function() {
return new this.constructor().copy(this);
},
copy: function(ray) {
this.origin.copy(ray.origin);
this.direction.copy(ray.direction);
return this;
},
at: function(t, target) {
if (target === void 0) {
console.warn("THREE.Ray: .at() target is now required");
target = new Vector3();
}
return target.copy(this.direction).multiplyScalar(t).add(this.origin);
},
lookAt: function(v) {
this.direction.copy(v).sub(this.origin).normalize();
return this;
},
recast: function(t) {
this.origin.copy(this.at(t, _vector$2));
return this;
},
closestPointToPoint: function(point, target) {
if (target === void 0) {
console.warn("THREE.Ray: .closestPointToPoint() target is now required");
target = new Vector3();
}
target.subVectors(point, this.origin);
var directionDistance = target.dot(this.direction);
if (directionDistance < 0) {
return target.copy(this.origin);
}
return target.copy(this.direction).multiplyScalar(directionDistance).add(this.origin);
},
distanceToPoint: function(point) {
return Math.sqrt(this.distanceSqToPoint(point));
},
distanceSqToPoint: function(point) {
var directionDistance = _vector$2.subVectors(point, this.origin).dot(this.direction);
if (directionDistance < 0) {
return this.origin.distanceToSquared(point);
}
_vector$2.copy(this.direction).multiplyScalar(directionDistance).add(this.origin);
return _vector$2.distanceToSquared(point);
},
distanceSqToSegment: function(v0, v1, optionalPointOnRay, optionalPointOnSegment) {
_segCenter.copy(v0).add(v1).multiplyScalar(0.5);
_segDir.copy(v1).sub(v0).normalize();
_diff.copy(this.origin).sub(_segCenter);
var segExtent = v0.distanceTo(v1) * 0.5;
var a01 = -this.direction.dot(_segDir);
var b0 = _diff.dot(this.direction);
var b1 = -_diff.dot(_segDir);
var c = _diff.lengthSq();
var det = Math.abs(1 - a01 * a01);
var s0, s1, sqrDist, extDet;
if (det > 0) {
s0 = a01 * b1 - b0;
s1 = a01 * b0 - b1;
extDet = segExtent * det;
if (s0 >= 0) {
if (s1 >= -extDet) {
if (s1 <= extDet) {
var invDet = 1 / det;
s0 *= invDet;
s1 *= invDet;
sqrDist = s0 * (s0 + a01 * s1 + 2 * b0) + s1 * (a01 * s0 + s1 + 2 * b1) + c;
} else {
s1 = segExtent;
s0 = Math.max(0, -(a01 * s1 + b0));
sqrDist = -s0 * s0 + s1 * (s1 + 2 * b1) + c;
}
} else {
s1 = -segExtent;
s0 = Math.max(0, -(a01 * s1 + b0));
sqrDist = -s0 * s0 + s1 * (s1 + 2 * b1) + c;
}
} else {
if (s1 <= -extDet) {
s0 = Math.max(0, -(-a01 * segExtent + b0));
s1 = s0 > 0 ? -segExtent : Math.min(Math.max(-segExtent, -b1), segExtent);
sqrDist = -s0 * s0 + s1 * (s1 + 2 * b1) + c;
} else if (s1 <= extDet) {
s0 = 0;
s1 = Math.min(Math.max(-segExtent, -b1), segExtent);
sqrDist = s1 * (s1 + 2 * b1) + c;
} else {
s0 = Math.max(0, -(a01 * segExtent + b0));
s1 = s0 > 0 ? segExtent : Math.min(Math.max(-segExtent, -b1), segExtent);
sqrDist = -s0 * s0 + s1 * (s1 + 2 * b1) + c;
}
}
} else {
s1 = a01 > 0 ? -segExtent : segExtent;
s0 = Math.max(0, -(a01 * s1 + b0));
sqrDist = -s0 * s0 + s1 * (s1 + 2 * b1) + c;
}
if (optionalPointOnRay) {
optionalPointOnRay.copy(this.direction).multiplyScalar(s0).add(this.origin);
}
if (optionalPointOnSegment) {
optionalPointOnSegment.copy(_segDir).multiplyScalar(s1).add(_segCenter);
}
return sqrDist;
},
intersectSphere: function(sphere, target) {
_vector$2.subVectors(sphere.center, this.origin);
var tca = _vector$2.dot(this.direction);
var d2 = _vector$2.dot(_vector$2) - tca * tca;
var radius2 = sphere.radius * sphere.radius;
if (d2 > radius2)
return null;
var thc = Math.sqrt(radius2 - d2);
var t0 = tca - thc;
var t1 = tca + thc;
if (t0 < 0 && t1 < 0)
return null;
if (t0 < 0)
return this.at(t1, target);
return this.at(t0, target);
},
intersectsSphere: function(sphere) {
return this.distanceSqToPoint(sphere.center) <= sphere.radius * sphere.radius;
},
distanceToPlane: function(plane) {
var denominator = plane.normal.dot(this.direction);
if (denominator === 0) {
if (plane.distanceToPoint(this.origin) === 0) {
return 0;
}
return null;
}
var t = -(this.origin.dot(plane.normal) + plane.constant) / denominator;
return t >= 0 ? t : null;
},
intersectPlane: function(plane, target) {
var t = this.distanceToPlane(plane);
if (t === null) {
return null;
}
return this.at(t, target);
},
intersectsPlane: function(plane) {
var distToPoint = plane.distanceToPoint(this.origin);
if (distToPoint === 0) {
return true;
}
var denominator = plane.normal.dot(this.direction);
if (denominator * distToPoint < 0) {
return true;
}
return false;
},
intersectBox: function(box, target) {
var tmin, tmax, tymin, tymax, tzmin, tzmax;
var invdirx = 1 / this.direction.x, invdiry = 1 / this.direction.y, invdirz = 1 / this.direction.z;
var origin = this.origin;
if (invdirx >= 0) {
tmin = (box.min.x - origin.x) * invdirx;
tmax = (box.max.x - origin.x) * invdirx;
} else {
tmin = (box.max.x - origin.x) * invdirx;
tmax = (box.min.x - origin.x) * invdirx;
}
if (invdiry >= 0) {
tymin = (box.min.y - origin.y) * invdiry;
tymax = (box.max.y - origin.y) * invdiry;
} else {
tymin = (box.max.y - origin.y) * invdiry;
tymax = (box.min.y - origin.y) * invdiry;
}
if (tmin > tymax || tymin > tmax)
return null;
if (tymin > tmin || tmin !== tmin)
tmin = tymin;
if (tymax < tmax || tmax !== tmax)
tmax = tymax;
if (invdirz >= 0) {
tzmin = (box.min.z - origin.z) * invdirz;
tzmax = (box.max.z - origin.z) * invdirz;
} else {
tzmin = (box.max.z - origin.z) * invdirz;
tzmax = (box.min.z - origin.z) * invdirz;
}
if (tmin > tzmax || tzmin > tmax)
return null;
if (tzmin > tmin || tmin !== tmin)
tmin = tzmin;
if (tzmax < tmax || tmax !== tmax)
tmax = tzmax;
if (tmax < 0)
return null;
return this.at(tmin >= 0 ? tmin : tmax, target);
},
intersectsBox: function(box) {
return this.intersectBox(box, _vector$2) !== null;
},
intersectTriangle: function(a, b, c, backfaceCulling, target) {
_edge1.subVectors(b, a);
_edge2.subVectors(c, a);
_normal.crossVectors(_edge1, _edge2);
var DdN = this.direction.dot(_normal);
var sign;
if (DdN > 0) {
if (backfaceCulling)
return null;
sign = 1;
} else if (DdN < 0) {
sign = -1;
DdN = -DdN;
} else {
return null;
}
_diff.subVectors(this.origin, a);
var DdQxE2 = sign * this.direction.dot(_edge2.crossVectors(_diff, _edge2));
if (DdQxE2 < 0) {
return null;
}
var DdE1xQ = sign * this.direction.dot(_edge1.cross(_diff));
if (DdE1xQ < 0) {
return null;
}
if (DdQxE2 + DdE1xQ > DdN) {
return null;
}
var QdN = -sign * _diff.dot(_normal);
if (QdN < 0) {
return null;
}
return this.at(QdN / DdN, target);
},
applyMatrix4: function(matrix4) {
this.origin.applyMatrix4(matrix4);
this.direction.transformDirection(matrix4);
return this;
},
equals: function(ray) {
return ray.origin.equals(this.origin) && ray.direction.equals(this.direction);
}
});
var _vector1 = new Vector3();
var _vector2 = new Vector3();
var _normalMatrix = new Matrix3();
function Plane(normal, constant) {
this.normal = normal !== void 0 ? normal : new Vector3(1, 0, 0);
this.constant = constant !== void 0 ? constant : 0;
}
Object.assign(Plane.prototype, {
isPlane: true,
set: function(normal, constant) {
this.normal.copy(normal);
this.constant = constant;
return this;
},
setComponents: function(x, y, z, w) {
this.normal.set(x, y, z);
this.constant = w;
return this;
},
setFromNormalAndCoplanarPoint: function(normal, point) {
this.normal.copy(normal);
this.constant = -point.dot(this.normal);
return this;
},
setFromCoplanarPoints: function(a, b, c) {
var normal = _vector1.subVectors(c, b).cross(_vector2.subVectors(a, b)).normalize();
this.setFromNormalAndCoplanarPoint(normal, a);
return this;
},
clone: function() {
return new this.constructor().copy(this);
},
copy: function(plane) {
this.normal.copy(plane.normal);
this.constant = plane.constant;
return this;
},
normalize: function() {
var inverseNormalLength = 1 / this.normal.length();
this.normal.multiplyScalar(inverseNormalLength);
this.constant *= inverseNormalLength;
return this;
},
negate: function() {
this.constant *= -1;
this.normal.negate();
return this;
},
distanceToPoint: function(point) {
return this.normal.dot(point) + this.constant;
},
distanceToSphere: function(sphere) {
return this.distanceToPoint(sphere.center) - sphere.radius;
},
projectPoint: function(point, target) {
if (target === void 0) {
console.warn("THREE.Plane: .projectPoint() target is now required");
target = new Vector3();
}
return target.copy(this.normal).multiplyScalar(-this.distanceToPoint(point)).add(point);
},
intersectLine: function(line, target) {
if (target === void 0) {
console.warn("THREE.Plane: .intersectLine() target is now required");
target = new Vector3();
}
var direction = line.delta(_vector1);
var denominator = this.normal.dot(direction);
if (denominator === 0) {
if (this.distanceToPoint(line.start) === 0) {
return target.copy(line.start);
}
return void 0;
}
var t = -(line.start.dot(this.normal) + this.constant) / denominator;
if (t < 0 || t > 1) {
return void 0;
}
return target.copy(direction).multiplyScalar(t).add(line.start);
},
intersectsLine: function(line) {
var startSign = this.distanceToPoint(line.start);
var endSign = this.distanceToPoint(line.end);
return startSign < 0 && endSign > 0 || endSign < 0 && startSign > 0;
},
intersectsBox: function(box) {
return box.intersectsPlane(this);
},
intersectsSphere: function(sphere) {
return sphere.intersectsPlane(this);
},
coplanarPoint: function(target) {
if (target === void 0) {
console.warn("THREE.Plane: .coplanarPoint() target is now required");
target = new Vector3();
}
return target.copy(this.normal).multiplyScalar(-this.constant);
},
applyMatrix4: function(matrix, optionalNormalMatrix) {
var normalMatrix = optionalNormalMatrix || _normalMatrix.getNormalMatrix(matrix);
var referencePoint = this.coplanarPoint(_vector1).applyMatrix4(matrix);
var normal = this.normal.applyMatrix3(normalMatrix).normalize();
this.constant = -referencePoint.dot(normal);
return this;
},
translate: function(offset) {
this.constant -= offset.dot(this.normal);
return this;
},
equals: function(plane) {
return plane.normal.equals(this.normal) && plane.constant === this.constant;
}
});
var _v0$1 = new Vector3();
var _v1$3 = new Vector3();
var _v2$1 = new Vector3();
var _v3 = new Vector3();
var _vab = new Vector3();
var _vac = new Vector3();
var _vbc = new Vector3();
var _vap = new Vector3();
var _vbp = new Vector3();
var _vcp = new Vector3();
function Triangle(a, b, c) {
this.a = a !== void 0 ? a : new Vector3();
this.b = b !== void 0 ? b : new Vector3();
this.c = c !== void 0 ? c : new Vector3();
}
Object.assign(Triangle, {
getNormal: function(a, b, c, target) {
if (target === void 0) {
console.warn("THREE.Triangle: .getNormal() target is now required");
target = new Vector3();
}
target.subVectors(c, b);
_v0$1.subVectors(a, b);
target.cross(_v0$1);
var targetLengthSq = target.lengthSq();
if (targetLengthSq > 0) {
return target.multiplyScalar(1 / Math.sqrt(targetLengthSq));
}
return target.set(0, 0, 0);
},
// static/instance method to calculate barycentric coordinates
// based on: http://www.blackpawn.com/texts/pointinpoly/default.html
getBarycoord: function(point, a, b, c, target) {
_v0$1.subVectors(c, a);
_v1$3.subVectors(b, a);
_v2$1.subVectors(point, a);
var dot00 = _v0$1.dot(_v0$1);
var dot01 = _v0$1.dot(_v1$3);
var dot02 = _v0$1.dot(_v2$1);
var dot11 = _v1$3.dot(_v1$3);
var dot12 = _v1$3.dot(_v2$1);
var denom = dot00 * dot11 - dot01 * dot01;
if (target === void 0) {
console.warn("THREE.Triangle: .getBarycoord() target is now required");
target = new Vector3();
}
if (denom === 0) {
return target.set(-2, -1, -1);
}
var invDenom = 1 / denom;
var u = (dot11 * dot02 - dot01 * dot12) * invDenom;
var v = (dot00 * dot12 - dot01 * dot02) * invDenom;
return target.set(1 - u - v, v, u);
},
containsPoint: function(point, a, b, c) {
Triangle.getBarycoord(point, a, b, c, _v3);
return _v3.x >= 0 && _v3.y >= 0 && _v3.x + _v3.y <= 1;
},
getUV: function(point, p1, p2, p3, uv1, uv2, uv3, target) {
this.getBarycoord(point, p1, p2, p3, _v3);
target.set(0, 0);
target.addScaledVector(uv1, _v3.x);
target.addScaledVector(uv2, _v3.y);
target.addScaledVector(uv3, _v3.z);
return target;
},
isFrontFacing: function(a, b, c, direction) {
_v0$1.subVectors(c, b);
_v1$3.subVectors(a, b);
return _v0$1.cross(_v1$3).dot(direction) < 0 ? true : false;
}
});
Object.assign(Triangle.prototype, {
set: function(a, b, c) {
this.a.copy(a);
this.b.copy(b);
this.c.copy(c);
return this;
},
setFromPointsAndIndices: function(points, i0, i1, i2) {
this.a.copy(points[i0]);
this.b.copy(points[i1]);
this.c.copy(points[i2]);
return this;
},
clone: function() {
return new this.constructor().copy(this);
},
copy: function(triangle) {
this.a.copy(triangle.a);
this.b.copy(triangle.b);
this.c.copy(triangle.c);
return this;
},
getArea: function() {
_v0$1.subVectors(this.c, this.b);
_v1$3.subVectors(this.a, this.b);
return _v0$1.cross(_v1$3).length() * 0.5;
},
getMidpoint: function(target) {
if (target === void 0) {
console.warn("THREE.Triangle: .getMidpoint() target is now required");
target = new Vector3();
}
return target.addVectors(this.a, this.b).add(this.c).multiplyScalar(1 / 3);
},
getNormal: function(target) {
return Triangle.getNormal(this.a, this.b, this.c, target);
},
getPlane: function(target) {
if (target === void 0) {
console.warn("THREE.Triangle: .getPlane() target is now required");
target = new Plane();
}
return target.setFromCoplanarPoints(this.a, this.b, this.c);
},
getBarycoord: function(point, target) {
return Triangle.getBarycoord(point, this.a, this.b, this.c, target);
},
getUV: function(point, uv1, uv2, uv3, target) {
return Triangle.getUV(point, this.a, this.b, this.c, uv1, uv2, uv3, target);
},
containsPoint: function(point) {
return Triangle.containsPoint(point, this.a, this.b, this.c);
},
isFrontFacing: function(direction) {
return Triangle.isFrontFacing(this.a, this.b, this.c, direction);
},
intersectsBox: function(box) {
return box.intersectsTriangle(this);
},
closestPointToPoint: function(p, target) {
if (target === void 0) {
console.warn("THREE.Triangle: .closestPointToPoint() target is now required");
target = new Vector3();
}
var a = this.a, b = this.b, c = this.c;
var v, w;
_vab.subVectors(b, a);
_vac.subVectors(c, a);
_vap.subVectors(p, a);
var d1 = _vab.dot(_vap);
var d2 = _vac.dot(_vap);
if (d1 <= 0 && d2 <= 0) {
return target.copy(a);
}
_vbp.subVectors(p, b);
var d3 = _vab.dot(_vbp);
var d4 = _vac.dot(_vbp);
if (d3 >= 0 && d4 <= d3) {
return target.copy(b);
}
var vc = d1 * d4 - d3 * d2;
if (vc <= 0 && d1 >= 0 && d3 <= 0) {
v = d1 / (d1 - d3);
return target.copy(a).addScaledVector(_vab, v);
}
_vcp.subVectors(p, c);
var d5 = _vab.dot(_vcp);
var d6 = _vac.dot(_vcp);
if (d6 >= 0 && d5 <= d6) {
return target.copy(c);
}
var vb = d5 * d2 - d1 * d6;
if (vb <= 0 && d2 >= 0 && d6 <= 0) {
w = d2 / (d2 - d6);
return target.copy(a).addScaledVector(_vac, w);
}
var va = d3 * d6 - d5 * d4;
if (va <= 0 && d4 - d3 >= 0 && d5 - d6 >= 0) {
_vbc.subVectors(c, b);
w = (d4 - d3) / (d4 - d3 + (d5 - d6));
return target.copy(b).addScaledVector(_vbc, w);
}
var denom = 1 / (va + vb + vc);
v = vb * denom;
w = vc * denom;
return target.copy(a).addScaledVector(_vab, v).addScaledVector(_vac, w);
},
equals: function(triangle) {
return triangle.a.equals(this.a) && triangle.b.equals(this.b) && triangle.c.equals(this.c);
}
});
var _colorKeywords = {
"aliceblue": 15792383,
"antiquewhite": 16444375,
"aqua": 65535,
"aquamarine": 8388564,
"azure": 15794175,
"beige": 16119260,
"bisque": 16770244,
"black": 0,
"blanchedalmond": 16772045,
"blue": 255,
"blueviolet": 9055202,
"brown": 10824234,
"burlywood": 14596231,
"cadetblue": 6266528,
"chartreuse": 8388352,
"chocolate": 13789470,
"coral": 16744272,
"cornflowerblue": 6591981,
"cornsilk": 16775388,
"crimson": 14423100,
"cyan": 65535,
"darkblue": 139,
"darkcyan": 35723,
"darkgoldenrod": 12092939,
"darkgray": 11119017,
"darkgreen": 25600,
"darkgrey": 11119017,
"darkkhaki": 12433259,
"darkmagenta": 9109643,
"darkolivegreen": 5597999,
"darkorange": 16747520,
"darkorchid": 10040012,
"darkred": 9109504,
"darksalmon": 15308410,
"darkseagreen": 9419919,
"darkslateblue": 4734347,
"darkslategray": 3100495,
"darkslategrey": 3100495,
"darkturquoise": 52945,
"darkviolet": 9699539,
"deeppink": 16716947,
"deepskyblue": 49151,
"dimgray": 6908265,
"dimgrey": 6908265,
"dodgerblue": 2003199,
"firebrick": 11674146,
"floralwhite": 16775920,
"forestgreen": 2263842,
"fuchsia": 16711935,
"gainsboro": 14474460,
"ghostwhite": 16316671,
"gold": 16766720,
"goldenrod": 14329120,
"gray": 8421504,
"green": 32768,
"greenyellow": 11403055,
"grey": 8421504,
"honeydew": 15794160,
"hotpink": 16738740,
"indianred": 13458524,
"indigo": 4915330,
"ivory": 16777200,
"khaki": 15787660,
"lavender": 15132410,
"lavenderblush": 16773365,
"lawngreen": 8190976,
"lemonchiffon": 16775885,
"lightblue": 11393254,
"lightcoral": 15761536,
"lightcyan": 14745599,
"lightgoldenrodyellow": 16448210,
"lightgray": 13882323,
"lightgreen": 9498256,
"lightgrey": 13882323,
"lightpink": 16758465,
"lightsalmon": 16752762,
"lightseagreen": 2142890,
"lightskyblue": 8900346,
"lightslategray": 7833753,
"lightslategrey": 7833753,
"lightsteelblue": 11584734,
"lightyellow": 16777184,
"lime": 65280,
"limegreen": 3329330,
"linen": 16445670,
"magenta": 16711935,
"maroon": 8388608,
"mediumaquamarine": 6737322,
"mediumblue": 205,
"mediumorchid": 12211667,
"mediumpurple": 9662683,
"mediumseagreen": 3978097,
"mediumslateblue": 8087790,
"mediumspringgreen": 64154,
"mediumturquoise": 4772300,
"mediumvioletred": 13047173,
"midnightblue": 1644912,
"mintcream": 16121850,
"mistyrose": 16770273,
"moccasin": 16770229,
"navajowhite": 16768685,
"navy": 128,
"oldlace": 16643558,
"olive": 8421376,
"olivedrab": 7048739,
"orange": 16753920,
"orangered": 16729344,
"orchid": 14315734,
"palegoldenrod": 15657130,
"palegreen": 10025880,
"paleturquoise": 11529966,
"palevioletred": 14381203,
"papayawhip": 16773077,
"peachpuff": 16767673,
"peru": 13468991,
"pink": 16761035,
"plum": 14524637,
"powderblue": 11591910,
"purple": 8388736,
"rebeccapurple": 6697881,
"red": 16711680,
"rosybrown": 12357519,
"royalblue": 4286945,
"saddlebrown": 9127187,
"salmon": 16416882,
"sandybrown": 16032864,
"seagreen": 3050327,
"seashell": 16774638,
"sienna": 10506797,
"silver": 12632256,
"skyblue": 8900331,
"slateblue": 6970061,
"slategray": 7372944,
"slategrey": 7372944,
"snow": 16775930,
"springgreen": 65407,
"steelblue": 4620980,
"tan": 13808780,
"teal": 32896,
"thistle": 14204888,
"tomato": 16737095,
"turquoise": 4251856,
"violet": 15631086,
"wheat": 16113331,
"white": 16777215,
"whitesmoke": 16119285,
"yellow": 16776960,
"yellowgreen": 10145074
};
var _hslA = { h: 0, s: 0, l: 0 };
var _hslB = { h: 0, s: 0, l: 0 };
function Color(r, g, b) {
if (g === void 0 && b === void 0) {
return this.set(r);
}
return this.setRGB(r, g, b);
}
function hue2rgb(p, q, t) {
if (t < 0)
t += 1;
if (t > 1)
t -= 1;
if (t < 1 / 6)
return p + (q - p) * 6 * t;
if (t < 1 / 2)
return q;
if (t < 2 / 3)
return p + (q - p) * 6 * (2 / 3 - t);
return p;
}
function SRGBToLinear(c) {
return c < 0.04045 ? c * 0.0773993808 : Math.pow(c * 0.9478672986 + 0.0521327014, 2.4);
}
function LinearToSRGB(c) {
return c < 31308e-7 ? c * 12.92 : 1.055 * Math.pow(c, 0.41666) - 0.055;
}
Object.assign(Color.prototype, {
isColor: true,
r: 1,
g: 1,
b: 1,
set: function(value) {
if (value && value.isColor) {
this.copy(value);
} else if (typeof value === "number") {
this.setHex(value);
} else if (typeof value === "string") {
this.setStyle(value);
}
return this;
},
setScalar: function(scalar) {
this.r = scalar;
this.g = scalar;
this.b = scalar;
return this;
},
setHex: function(hex) {
hex = Math.floor(hex);
this.r = (hex >> 16 & 255) / 255;
this.g = (hex >> 8 & 255) / 255;
this.b = (hex & 255) / 255;
return this;
},
setRGB: function(r, g, b) {
this.r = r;
this.g = g;
this.b = b;
return this;
},
setHSL: function(h, s, l) {
h = MathUtils.euclideanModulo(h, 1);
s = MathUtils.clamp(s, 0, 1);
l = MathUtils.clamp(l, 0, 1);
if (s === 0) {
this.r = this.g = this.b = l;
} else {
var p = l <= 0.5 ? l * (1 + s) : l + s - l * s;
var q = 2 * l - p;
this.r = hue2rgb(q, p, h + 1 / 3);
this.g = hue2rgb(q, p, h);
this.b = hue2rgb(q, p, h - 1 / 3);
}
return this;
},
setStyle: function(style) {
function handleAlpha(string) {
if (string === void 0)
return;
if (parseFloat(string) < 1) {
console.warn("THREE.Color: Alpha component of " + style + " will be ignored.");
}
}
var m;
if (m = /^((?:rgb|hsl)a?)\(\s*([^\)]*)\)/.exec(style)) {
var color;
var name = m[1];
var components = m[2];
switch (name) {
case "rgb":
case "rgba":
if (color = /^(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(components)) {
this.r = Math.min(255, parseInt(color[1], 10)) / 255;
this.g = Math.min(255, parseInt(color[2], 10)) / 255;
this.b = Math.min(255, parseInt(color[3], 10)) / 255;
handleAlpha(color[5]);
return this;
}
if (color = /^(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(components)) {
this.r = Math.min(100, parseInt(color[1], 10)) / 100;
this.g = Math.min(100, parseInt(color[2], 10)) / 100;
this.b = Math.min(100, parseInt(color[3], 10)) / 100;
handleAlpha(color[5]);
return this;
}
break;
case "hsl":
case "hsla":
if (color = /^([0-9]*\.?[0-9]+)\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(components)) {
var h = parseFloat(color[1]) / 360;
var s = parseInt(color[2], 10) / 100;
var l = parseInt(color[3], 10) / 100;
handleAlpha(color[5]);
return this.setHSL(h, s, l);
}
break;
}
} else if (m = /^\#([A-Fa-f0-9]+)$/.exec(style)) {
var hex = m[1];
var size = hex.length;
if (size === 3) {
this.r = parseInt(hex.charAt(0) + hex.charAt(0), 16) / 255;
this.g = parseInt(hex.charAt(1) + hex.charAt(1), 16) / 255;
this.b = parseInt(hex.charAt(2) + hex.charAt(2), 16) / 255;
return this;
} else if (size === 6) {
this.r = parseInt(hex.charAt(0) + hex.charAt(1), 16) / 255;
this.g = parseInt(hex.charAt(2) + hex.charAt(3), 16) / 255;
this.b = parseInt(hex.charAt(4) + hex.charAt(5), 16) / 255;
return this;
}
}
if (style && style.length > 0) {
return this.setColorName(style);
}
return this;
},
setColorName: function(style) {
var hex = _colorKeywords[style];
if (hex !== void 0) {
this.setHex(hex);
} else {
console.warn("THREE.Color: Unknown color " + style);
}
return this;
},
clone: function() {
return new this.constructor(this.r, this.g, this.b);
},
copy: function(color) {
this.r = color.r;
this.g = color.g;
this.b = color.b;
return this;
},
copyGammaToLinear: function(color, gammaFactor) {
if (gammaFactor === void 0)
gammaFactor = 2;
this.r = Math.pow(color.r, gammaFactor);
this.g = Math.pow(color.g, gammaFactor);
this.b = Math.pow(color.b, gammaFactor);
return this;
},
copyLinearToGamma: function(color, gammaFactor) {
if (gammaFactor === void 0)
gammaFactor = 2;
var safeInverse = gammaFactor > 0 ? 1 / gammaFactor : 1;
this.r = Math.pow(color.r, safeInverse);
this.g = Math.pow(color.g, safeInverse);
this.b = Math.pow(color.b, safeInverse);
return this;
},
convertGammaToLinear: function(gammaFactor) {
this.copyGammaToLinear(this, gammaFactor);
return this;
},
convertLinearToGamma: function(gammaFactor) {
this.copyLinearToGamma(this, gammaFactor);
return this;
},
copySRGBToLinear: function(color) {
this.r = SRGBToLinear(color.r);
this.g = SRGBToLinear(color.g);
this.b = SRGBToLinear(color.b);
return this;
},
copyLinearToSRGB: function(color) {
this.r = LinearToSRGB(color.r);
this.g = LinearToSRGB(color.g);
this.b = LinearToSRGB(color.b);
return this;
},
convertSRGBToLinear: function() {
this.copySRGBToLinear(this);
return this;
},
convertLinearToSRGB: function() {
this.copyLinearToSRGB(this);
return this;
},
getHex: function() {
return this.r * 255 << 16 ^ this.g * 255 << 8 ^ this.b * 255 << 0;
},
getHexString: function() {
return ("000000" + this.getHex().toString(16)).slice(-6);
},
getHSL: function(target) {
if (target === void 0) {
console.warn("THREE.Color: .getHSL() target is now required");
target = { h: 0, s: 0, l: 0 };
}
var r = this.r, g = this.g, b = this.b;
var max = Math.max(r, g, b);
var min = Math.min(r, g, b);
var hue, saturation;
var lightness = (min + max) / 2;
if (min === max) {
hue = 0;
saturation = 0;
} else {
var delta = max - min;
saturation = lightness <= 0.5 ? delta / (max + min) : delta / (2 - max - min);
switch (max) {
case r:
hue = (g - b) / delta + (g < b ? 6 : 0);
break;
case g:
hue = (b - r) / delta + 2;
break;
case b:
hue = (r - g) / delta + 4;
break;
}
hue /= 6;
}
target.h = hue;
target.s = saturation;
target.l = lightness;
return target;
},
getStyle: function() {
return "rgb(" + (this.r * 255 | 0) + "," + (this.g * 255 | 0) + "," + (this.b * 255 | 0) + ")";
},
offsetHSL: function(h, s, l) {
this.getHSL(_hslA);
_hslA.h += h;
_hslA.s += s;
_hslA.l += l;
this.setHSL(_hslA.h, _hslA.s, _hslA.l);
return this;
},
add: function(color) {
this.r += color.r;
this.g += color.g;
this.b += color.b;
return this;
},
addColors: function(color1, color2) {
this.r = color1.r + color2.r;
this.g = color1.g + color2.g;
this.b = color1.b + color2.b;
return this;
},
addScalar: function(s) {
this.r += s;
this.g += s;
this.b += s;
return this;
},
sub: function(color) {
this.r = Math.max(0, this.r - color.r);
this.g = Math.max(0, this.g - color.g);
this.b = Math.max(0, this.b - color.b);
return this;
},
multiply: function(color) {
this.r *= color.r;
this.g *= color.g;
this.b *= color.b;
return this;
},
multiplyScalar: function(s) {
this.r *= s;
this.g *= s;
this.b *= s;
return this;
},
lerp: function(color, alpha) {
this.r += (color.r - this.r) * alpha;
this.g += (color.g - this.g) * alpha;
this.b += (color.b - this.b) * alpha;
return this;
},
lerpHSL: function(color, alpha) {
this.getHSL(_hslA);
color.getHSL(_hslB);
var h = MathUtils.lerp(_hslA.h, _hslB.h, alpha);
var s = MathUtils.lerp(_hslA.s, _hslB.s, alpha);
var l = MathUtils.lerp(_hslA.l, _hslB.l, alpha);
this.setHSL(h, s, l);
return this;
},
equals: function(c) {
return c.r === this.r && c.g === this.g && c.b === this.b;
},
fromArray: function(array, offset) {
if (offset === void 0)
offset = 0;
this.r = array[offset];
this.g = array[offset + 1];
this.b = array[offset + 2];
return this;
},
toArray: function(array, offset) {
if (array === void 0)
array = [];
if (offset === void 0)
offset = 0;
array[offset] = this.r;
array[offset + 1] = this.g;
array[offset + 2] = this.b;
return array;
},
toJSON: function() {
return this.getHex();
}
});
Color.NAMES = _colorKeywords;
function Face3(a, b, c, normal, color, materialIndex) {
this.a = a;
this.b = b;
this.c = c;
this.normal = normal && normal.isVector3 ? normal : new Vector3();
this.vertexNormals = Array.isArray(normal) ? normal : [];
this.color = color && color.isColor ? color : new Color();
this.vertexColors = Array.isArray(color) ? color : [];
this.materialIndex = materialIndex !== void 0 ? materialIndex : 0;
}
Object.assign(Face3.prototype, {
clone: function() {
return new this.constructor().copy(this);
},
copy: function(source) {
this.a = source.a;
this.b = source.b;
this.c = source.c;
this.normal.copy(source.normal);
this.color.copy(source.color);
this.materialIndex = source.materialIndex;
for (var i2 = 0, il = source.vertexNormals.length; i2 < il; i2++) {
this.vertexNormals[i2] = source.vertexNormals[i2].clone();
}
for (var i2 = 0, il = source.vertexColors.length; i2 < il; i2++) {
this.vertexColors[i2] = source.vertexColors[i2].clone();
}
return this;
}
});
var materialId = 0;
function Material() {
Object.defineProperty(this, "id", { value: materialId++ });
this.uuid = MathUtils.generateUUID();
this.name = "";
this.type = "Material";
this.fog = true;
this.blending = NormalBlending;
this.side = FrontSide;
this.flatShading = false;
this.vertexTangents = false;
this.vertexColors = NoColors;
this.opacity = 1;
this.transparent = false;
this.blendSrc = SrcAlphaFactor;
this.blendDst = OneMinusSrcAlphaFactor;
this.blendEquation = AddEquation;
this.blendSrcAlpha = null;
this.blendDstAlpha = null;
this.blendEquationAlpha = null;
this.depthFunc = LessEqualDepth;
this.depthTest = true;
this.depthWrite = true;
this.stencilWriteMask = 255;
this.stencilFunc = AlwaysStencilFunc;
this.stencilRef = 0;
this.stencilFuncMask = 255;
this.stencilFail = KeepStencilOp;
this.stencilZFail = KeepStencilOp;
this.stencilZPass = KeepStencilOp;
this.stencilWrite = false;
this.clippingPlanes = null;
this.clipIntersection = false;
this.clipShadows = false;
this.shadowSide = null;
this.colorWrite = true;
this.precision = null;
this.polygonOffset = false;
this.polygonOffsetFactor = 0;
this.polygonOffsetUnits = 0;
this.dithering = false;
this.alphaTest = 0;
this.premultipliedAlpha = false;
this.visible = true;
this.toneMapped = true;
this.userData = {};
this.version = 0;
}
Material.prototype = Object.assign(Object.create(EventDispatcher.prototype), {
constructor: Material,
isMaterial: true,
onBeforeCompile: function() {
},
setValues: function(values) {
if (values === void 0)
return;
for (var key in values) {
var newValue = values[key];
if (newValue === void 0) {
console.warn("THREE.Material: '" + key + "' parameter is undefined.");
continue;
}
if (key === "shading") {
console.warn("THREE." + this.type + ": .shading has been removed. Use the boolean .flatShading instead.");
this.flatShading = newValue === FlatShading ? true : false;
continue;
}
var currentValue = this[key];
if (currentValue === void 0) {
console.warn("THREE." + this.type + ": '" + key + "' is not a property of this material.");
continue;
}
if (currentValue && currentValue.isColor) {
currentValue.set(newValue);
} else if (currentValue && currentValue.isVector3 && (newValue && newValue.isVector3)) {
currentValue.copy(newValue);
} else {
this[key] = newValue;
}
}
},
toJSON: function(meta) {
var isRoot = meta === void 0 || typeof meta === "string";
if (isRoot) {
meta = {
textures: {},
images: {}
};
}
var data = {
metadata: {
version: 4.5,
type: "Material",
generator: "Material.toJSON"
}
};
data.uuid = this.uuid;
data.type = this.type;
if (this.name !== "")
data.name = this.name;
if (this.color && this.color.isColor)
data.color = this.color.getHex();
if (this.roughness !== void 0)
data.roughness = this.roughness;
if (this.metalness !== void 0)
data.metalness = this.metalness;
if (this.sheen && this.sheen.isColor)
data.sheen = this.sheen.getHex();
if (this.emissive && this.emissive.isColor)
data.emissive = this.emissive.getHex();
if (this.emissiveIntensity && this.emissiveIntensity !== 1)
data.emissiveIntensity = this.emissiveIntensity;
if (this.specular && this.specular.isColor)
data.specular = this.specular.getHex();
if (this.shininess !== void 0)
data.shininess = this.shininess;
if (this.clearcoat !== void 0)
data.clearcoat = this.clearcoat;
if (this.clearcoatRoughness !== void 0)
data.clearcoatRoughness = this.clearcoatRoughness;
if (this.clearcoatNormalMap && this.clearcoatNormalMap.isTexture) {
data.clearcoatNormalMap = this.clearcoatNormalMap.toJSON(meta).uuid;
data.clearcoatNormalScale = this.clearcoatNormalScale.toArray();
}
if (this.map && this.map.isTexture)
data.map = this.map.toJSON(meta).uuid;
if (this.matcap && this.matcap.isTexture)
data.matcap = this.matcap.toJSON(meta).uuid;
if (this.alphaMap && this.alphaMap.isTexture)
data.alphaMap = this.alphaMap.toJSON(meta).uuid;
if (this.lightMap && this.lightMap.isTexture)
data.lightMap = this.lightMap.toJSON(meta).uuid;
if (this.aoMap && this.aoMap.isTexture) {
data.aoMap = this.aoMap.toJSON(meta).uuid;
data.aoMapIntensity = this.aoMapIntensity;
}
if (this.bumpMap && this.bumpMap.isTexture) {
data.bumpMap = this.bumpMap.toJSON(meta).uuid;
data.bumpScale = this.bumpScale;
}
if (this.normalMap && this.normalMap.isTexture) {
data.normalMap = this.normalMap.toJSON(meta).uuid;
data.normalMapType = this.normalMapType;
data.normalScale = this.normalScale.toArray();
}
if (this.displacementMap && this.displacementMap.isTexture) {
data.displacementMap = this.displacementMap.toJSON(meta).uuid;
data.displacementScale = this.displacementScale;
data.displacementBias = this.displacementBias;
}
if (this.roughnessMap && this.roughnessMap.isTexture)
data.roughnessMap = this.roughnessMap.toJSON(meta).uuid;
if (this.metalnessMap && this.metalnessMap.isTexture)
data.metalnessMap = this.metalnessMap.toJSON(meta).uuid;
if (this.emissiveMap && this.emissiveMap.isTexture)
data.emissiveMap = this.emissiveMap.toJSON(meta).uuid;
if (this.specularMap && this.specularMap.isTexture)
data.specularMap = this.specularMap.toJSON(meta).uuid;
if (this.envMap && this.envMap.isTexture) {
data.envMap = this.envMap.toJSON(meta).uuid;
data.reflectivity = this.reflectivity;
data.refractionRatio = this.refractionRatio;
if (this.combine !== void 0)
data.combine = this.combine;
if (this.envMapIntensity !== void 0)
data.envMapIntensity = this.envMapIntensity;
}
if (this.gradientMap && this.gradientMap.isTexture) {
data.gradientMap = this.gradientMap.toJSON(meta).uuid;
}
if (this.size !== void 0)
data.size = this.size;
if (this.sizeAttenuation !== void 0)
data.sizeAttenuation = this.sizeAttenuation;
if (this.blending !== NormalBlending)
data.blending = this.blending;
if (this.flatShading === true)
data.flatShading = this.flatShading;
if (this.side !== FrontSide)
data.side = this.side;
if (this.vertexColors !== NoColors)
data.vertexColors = this.vertexColors;
if (this.opacity < 1)
data.opacity = this.opacity;
if (this.transparent === true)
data.transparent = this.transparent;
data.depthFunc = this.depthFunc;
data.depthTest = this.depthTest;
data.depthWrite = this.depthWrite;
data.stencilWrite = this.stencilWrite;
data.stencilWriteMask = this.stencilWriteMask;
data.stencilFunc = this.stencilFunc;
data.stencilRef = this.stencilRef;
data.stencilFuncMask = this.stencilFuncMask;
data.stencilFail = this.stencilFail;
data.stencilZFail = this.stencilZFail;
data.stencilZPass = this.stencilZPass;
if (this.rotation && this.rotation !== 0)
data.rotation = this.rotation;
if (this.polygonOffset === true)
data.polygonOffset = true;
if (this.polygonOffsetFactor !== 0)
data.polygonOffsetFactor = this.polygonOffsetFactor;
if (this.polygonOffsetUnits !== 0)
data.polygonOffsetUnits = this.polygonOffsetUnits;
if (this.linewidth && this.linewidth !== 1)
data.linewidth = this.linewidth;
if (this.dashSize !== void 0)
data.dashSize = this.dashSize;
if (this.gapSize !== void 0)
data.gapSize = this.gapSize;
if (this.scale !== void 0)
data.scale = this.scale;
if (this.dithering === true)
data.dithering = true;
if (this.alphaTest > 0)
data.alphaTest = this.alphaTest;
if (this.premultipliedAlpha === true)
data.premultipliedAlpha = this.premultipliedAlpha;
if (this.wireframe === true)
data.wireframe = this.wireframe;
if (this.wireframeLinewidth > 1)
data.wireframeLinewidth = this.wireframeLinewidth;
if (this.wireframeLinecap !== "round")
data.wireframeLinecap = this.wireframeLinecap;
if (this.wireframeLinejoin !== "round")
data.wireframeLinejoin = this.wireframeLinejoin;
if (this.morphTargets === true)
data.morphTargets = true;
if (this.morphNormals === true)
data.morphNormals = true;
if (this.skinning === true)
data.skinning = true;
if (this.visible === false)
data.visible = false;
if (this.toneMapped === false)
data.toneMapped = false;
if (JSON.stringify(this.userData) !== "{}")
data.userData = this.userData;
function extractFromCache(cache) {
var values = [];
for (var key in cache) {
var data2 = cache[key];
delete data2.metadata;
values.push(data2);
}
return values;
}
if (isRoot) {
var textures = extractFromCache(meta.textures);
var images = extractFromCache(meta.images);
if (textures.length > 0)
data.textures = textures;
if (images.length > 0)
data.images = images;
}
return data;
},
clone: function() {
return new this.constructor().copy(this);
},
copy: function(source) {
this.name = source.name;
this.fog = source.fog;
this.blending = source.blending;
this.side = source.side;
this.flatShading = source.flatShading;
this.vertexTangents = source.vertexTangents;
this.vertexColors = source.vertexColors;
this.opacity = source.opacity;
this.transparent = source.transparent;
this.blendSrc = source.blendSrc;
this.blendDst = source.blendDst;
this.blendEquation = source.blendEquation;
this.blendSrcAlpha = source.blendSrcAlpha;
this.blendDstAlpha = source.blendDstAlpha;
this.blendEquationAlpha = source.blendEquationAlpha;
this.depthFunc = source.depthFunc;
this.depthTest = source.depthTest;
this.depthWrite = source.depthWrite;
this.stencilWriteMask = source.stencilWriteMask;
this.stencilFunc = source.stencilFunc;
this.stencilRef = source.stencilRef;
this.stencilFuncMask = source.stencilFuncMask;
this.stencilFail = source.stencilFail;
this.stencilZFail = source.stencilZFail;
this.stencilZPass = source.stencilZPass;
this.stencilWrite = source.stencilWrite;
var srcPlanes = source.clippingPlanes, dstPlanes = null;
if (srcPlanes !== null) {
var n = srcPlanes.length;
dstPlanes = new Array(n);
for (var i2 = 0; i2 !== n; ++i2)
dstPlanes[i2] = srcPlanes[i2].clone();
}
this.clippingPlanes = dstPlanes;
this.clipIntersection = source.clipIntersection;
this.clipShadows = source.clipShadows;
this.shadowSide = source.shadowSide;
this.colorWrite = source.colorWrite;
this.precision = source.precision;
this.polygonOffset = source.polygonOffset;
this.polygonOffsetFactor = source.polygonOffsetFactor;
this.polygonOffsetUnits = source.polygonOffsetUnits;
this.dithering = source.dithering;
this.alphaTest = source.alphaTest;
this.premultipliedAlpha = source.premultipliedAlpha;
this.visible = source.visible;
this.toneMapped = source.toneMapped;
this.userData = JSON.parse(JSON.stringify(source.userData));
return this;
},
dispose: function() {
this.dispatchEvent({ type: "dispose" });
}
});
Object.defineProperty(Material.prototype, "needsUpdate", {
set: function(value) {
if (value === true)
this.version++;
}
});
function MeshBasicMaterial(parameters) {
Material.call(this);
this.type = "MeshBasicMaterial";
this.color = new Color(16777215);
this.map = null;
this.lightMap = null;
this.lightMapIntensity = 1;
this.aoMap = null;
this.aoMapIntensity = 1;
this.specularMap = null;
this.alphaMap = null;
this.envMap = null;
this.combine = MultiplyOperation;
this.reflectivity = 1;
this.refractionRatio = 0.98;
this.wireframe = false;
this.wireframeLinewidth = 1;
this.wireframeLinecap = "round";
this.wireframeLinejoin = "round";
this.skinning = false;
this.morphTargets = false;
this.setValues(parameters);
}
MeshBasicMaterial.prototype = Object.create(Material.prototype);
MeshBasicMaterial.prototype.constructor = MeshBasicMaterial;
MeshBasicMaterial.prototype.isMeshBasicMaterial = true;
MeshBasicMaterial.prototype.copy = function(source) {
Material.prototype.copy.call(this, source);
this.color.copy(source.color);
this.map = source.map;
this.lightMap = source.lightMap;
this.lightMapIntensity = source.lightMapIntensity;
this.aoMap = source.aoMap;
this.aoMapIntensity = source.aoMapIntensity;
this.specularMap = source.specularMap;
this.alphaMap = source.alphaMap;
this.envMap = source.envMap;
this.combine = source.combine;
this.reflectivity = source.reflectivity;
this.refractionRatio = source.refractionRatio;
this.wireframe = source.wireframe;
this.wireframeLinewidth = source.wireframeLinewidth;
this.wireframeLinecap = source.wireframeLinecap;
this.wireframeLinejoin = source.wireframeLinejoin;
this.skinning = source.skinning;
this.morphTargets = source.morphTargets;
return this;
};
var _vector$3 = new Vector3();
function BufferAttribute(array, itemSize, normalized) {
if (Array.isArray(array)) {
throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");
}
this.name = "";
this.array = array;
this.itemSize = itemSize;
this.count = array !== void 0 ? array.length / itemSize : 0;
this.normalized = normalized === true;
this.usage = StaticDrawUsage;
this.updateRange = { offset: 0, count: -1 };
this.version = 0;
}
Object.defineProperty(BufferAttribute.prototype, "needsUpdate", {
set: function(value) {
if (value === true)
this.version++;
}
});
Object.assign(BufferAttribute.prototype, {
isBufferAttribute: true,
onUploadCallback: function() {
},
setUsage: function(value) {
this.usage = value;
return this;
},
copy: function(source) {
this.name = source.name;
this.array = new source.array.constructor(source.array);
this.itemSize = source.itemSize;
this.count = source.count;
this.normalized = source.normalized;
this.usage = source.usage;
return this;
},
copyAt: function(index1, attribute, index2) {
index1 *= this.itemSize;
index2 *= attribute.itemSize;
for (var i2 = 0, l = this.itemSize; i2 < l; i2++) {
this.array[index1 + i2] = attribute.array[index2 + i2];
}
return this;
},
copyArray: function(array) {
this.array.set(array);
return this;
},
copyColorsArray: function(colors) {
var array = this.array, offset = 0;
for (var i2 = 0, l = colors.length; i2 < l; i2++) {
var color = colors[i2];
if (color === void 0) {
console.warn("THREE.BufferAttribute.copyColorsArray(): color is undefined", i2);
color = new Color();
}
array[offset++] = color.r;
array[offset++] = color.g;
array[offset++] = color.b;
}
return this;
},
copyVector2sArray: function(vectors) {
var array = this.array, offset = 0;
for (var i2 = 0, l = vectors.length; i2 < l; i2++) {
var vector = vectors[i2];
if (vector === void 0) {
console.warn("THREE.BufferAttribute.copyVector2sArray(): vector is undefined", i2);
vector = new Vector2();
}
array[offset++] = vector.x;
array[offset++] = vector.y;
}
return this;
},
copyVector3sArray: function(vectors) {
var array = this.array, offset = 0;
for (var i2 = 0, l = vectors.length; i2 < l; i2++) {
var vector = vectors[i2];
if (vector === void 0) {
console.warn("THREE.BufferAttribute.copyVector3sArray(): vector is undefined", i2);
vector = new Vector3();
}
array[offset++] = vector.x;
array[offset++] = vector.y;
array[offset++] = vector.z;
}
return this;
},
copyVector4sArray: function(vectors) {
var array = this.array, offset = 0;
for (var i2 = 0, l = vectors.length; i2 < l; i2++) {
var vector = vectors[i2];
if (vector === void 0) {
console.warn("THREE.BufferAttribute.copyVector4sArray(): vector is undefined", i2);
vector = new Vector4();
}
array[offset++] = vector.x;
array[offset++] = vector.y;
array[offset++] = vector.z;
array[offset++] = vector.w;
}
return this;
},
applyMatrix3: function(m) {
for (var i2 = 0, l = this.count; i2 < l; i2++) {
_vector$3.x = this.getX(i2);
_vector$3.y = this.getY(i2);
_vector$3.z = this.getZ(i2);
_vector$3.applyMatrix3(m);
this.setXYZ(i2, _vector$3.x, _vector$3.y, _vector$3.z);
}
return this;
},
applyMatrix4: function(m) {
for (var i2 = 0, l = this.count; i2 < l; i2++) {
_vector$3.x = this.getX(i2);
_vector$3.y = this.getY(i2);
_vector$3.z = this.getZ(i2);
_vector$3.applyMatrix4(m);
this.setXYZ(i2, _vector$3.x, _vector$3.y, _vector$3.z);
}
return this;
},
applyNormalMatrix: function(m) {
for (var i2 = 0, l = this.count; i2 < l; i2++) {
_vector$3.x = this.getX(i2);
_vector$3.y = this.getY(i2);
_vector$3.z = this.getZ(i2);
_vector$3.applyNormalMatrix(m);
this.setXYZ(i2, _vector$3.x, _vector$3.y, _vector$3.z);
}
return this;
},
transformDirection: function(m) {
for (var i2 = 0, l = this.count; i2 < l; i2++) {
_vector$3.x = this.getX(i2);
_vector$3.y = this.getY(i2);
_vector$3.z = this.getZ(i2);
_vector$3.transformDirection(m);
this.setXYZ(i2, _vector$3.x, _vector$3.y, _vector$3.z);
}
return this;
},
set: function(value, offset) {
if (offset === void 0)
offset = 0;
this.array.set(value, offset);
return this;
},
getX: function(index) {
return this.array[index * this.itemSize];
},
setX: function(index, x) {
this.array[index * this.itemSize] = x;
return this;
},
getY: function(index) {
return this.array[index * this.itemSize + 1];
},
setY: function(index, y) {
this.array[index * this.itemSize + 1] = y;
return this;
},
getZ: function(index) {
return this.array[index * this.itemSize + 2];
},
setZ: function(index, z) {
this.array[index * this.itemSize + 2] = z;
return this;
},
getW: function(index) {
return this.array[index * this.itemSize + 3];
},
setW: function(index, w) {
this.array[index * this.itemSize + 3] = w;
return this;
},
setXY: function(index, x, y) {
index *= this.itemSize;
this.array[index + 0] = x;
this.array[index + 1] = y;
return this;
},
setXYZ: function(index, x, y, z) {
index *= this.itemSize;
this.array[index + 0] = x;
this.array[index + 1] = y;
this.array[index + 2] = z;
return this;
},
setXYZW: function(index, x, y, z, w) {
index *= this.itemSize;
this.array[index + 0] = x;
this.array[index + 1] = y;
this.array[index + 2] = z;
this.array[index + 3] = w;
return this;
},
onUpload: function(callback) {
this.onUploadCallback = callback;
return this;
},
clone: function() {
return new this.constructor(this.array, this.itemSize).copy(this);
},
toJSON: function() {
return {
itemSize: this.itemSize,
type: this.array.constructor.name,
array: Array.prototype.slice.call(this.array),
normalized: this.normalized
};
}
});
function Int8BufferAttribute(array, itemSize, normalized) {
BufferAttribute.call(this, new Int8Array(array), itemSize, normalized);
}
Int8BufferAttribute.prototype = Object.create(BufferAttribute.prototype);
Int8BufferAttribute.prototype.constructor = Int8BufferAttribute;
function Uint8BufferAttribute(array, itemSize, normalized) {
BufferAttribute.call(this, new Uint8Array(array), itemSize, normalized);
}
Uint8BufferAttribute.prototype = Object.create(BufferAttribute.prototype);
Uint8BufferAttribute.prototype.constructor = Uint8BufferAttribute;
function Uint8ClampedBufferAttribute(array, itemSize, normalized) {
BufferAttribute.call(this, new Uint8ClampedArray(array), itemSize, normalized);
}
Uint8ClampedBufferAttribute.prototype = Object.create(BufferAttribute.prototype);
Uint8ClampedBufferAttribute.prototype.constructor = Uint8ClampedBufferAttribute;
function Int16BufferAttribute(array, itemSize, normalized) {
BufferAttribute.call(this, new Int16Array(array), itemSize, normalized);
}
Int16BufferAttribute.prototype = Object.create(BufferAttribute.prototype);
Int16BufferAttribute.prototype.constructor = Int16BufferAttribute;
function Uint16BufferAttribute(array, itemSize, normalized) {
BufferAttribute.call(this, new Uint16Array(array), itemSize, normalized);
}
Uint16BufferAttribute.prototype = Object.create(BufferAttribute.prototype);
Uint16BufferAttribute.prototype.constructor = Uint16BufferAttribute;
function Int32BufferAttribute(array, itemSize, normalized) {
BufferAttribute.call(this, new Int32Array(array), itemSize, normalized);
}
Int32BufferAttribute.prototype = Object.create(BufferAttribute.prototype);
Int32BufferAttribute.prototype.constructor = Int32BufferAttribute;
function Uint32BufferAttribute(array, itemSize, normalized) {
BufferAttribute.call(this, new Uint32Array(array), itemSize, normalized);
}
Uint32BufferAttribute.prototype = Object.create(BufferAttribute.prototype);
Uint32BufferAttribute.prototype.constructor = Uint32BufferAttribute;
function Float32BufferAttribute(array, itemSize, normalized) {
BufferAttribute.call(this, new Float32Array(array), itemSize, normalized);
}
Float32BufferAttribute.prototype = Object.create(BufferAttribute.prototype);
Float32BufferAttribute.prototype.constructor = Float32BufferAttribute;
function Float64BufferAttribute(array, itemSize, normalized) {
BufferAttribute.call(this, new Float64Array(array), itemSize, normalized);
}
Float64BufferAttribute.prototype = Object.create(BufferAttribute.prototype);
Float64BufferAttribute.prototype.constructor = Float64BufferAttribute;
function DirectGeometry() {
this.vertices = [];
this.normals = [];
this.colors = [];
this.uvs = [];
this.uvs2 = [];
this.groups = [];
this.morphTargets = {};
this.skinWeights = [];
this.skinIndices = [];
this.boundingBox = null;
this.boundingSphere = null;
this.verticesNeedUpdate = false;
this.normalsNeedUpdate = false;
this.colorsNeedUpdate = false;
this.uvsNeedUpdate = false;
this.groupsNeedUpdate = false;
}
Object.assign(DirectGeometry.prototype, {
computeGroups: function(geometry) {
var group;
var groups = [];
var materialIndex = void 0;
var faces = geometry.faces;
for (var i2 = 0; i2 < faces.length; i2++) {
var face = faces[i2];
if (face.materialIndex !== materialIndex) {
materialIndex = face.materialIndex;
if (group !== void 0) {
group.count = i2 * 3 - group.start;
groups.push(group);
}
group = {
start: i2 * 3,
materialIndex
};
}
}
if (group !== void 0) {
group.count = i2 * 3 - group.start;
groups.push(group);
}
this.groups = groups;
},
fromGeometry: function(geometry) {
var faces = geometry.faces;
var vertices = geometry.vertices;
var faceVertexUvs = geometry.faceVertexUvs;
var hasFaceVertexUv = faceVertexUvs[0] && faceVertexUvs[0].length > 0;
var hasFaceVertexUv2 = faceVertexUvs[1] && faceVertexUvs[1].length > 0;
var morphTargets = geometry.morphTargets;
var morphTargetsLength = morphTargets.length;
var morphTargetsPosition;
if (morphTargetsLength > 0) {
morphTargetsPosition = [];
for (var i2 = 0; i2 < morphTargetsLength; i2++) {
morphTargetsPosition[i2] = {
name: morphTargets[i2].name,
data: []
};
}
this.morphTargets.position = morphTargetsPosition;
}
var morphNormals = geometry.morphNormals;
var morphNormalsLength = morphNormals.length;
var morphTargetsNormal;
if (morphNormalsLength > 0) {
morphTargetsNormal = [];
for (var i2 = 0; i2 < morphNormalsLength; i2++) {
morphTargetsNormal[i2] = {
name: morphNormals[i2].name,
data: []
};
}
this.morphTargets.normal = morphTargetsNormal;
}
var skinIndices = geometry.skinIndices;
var skinWeights = geometry.skinWeights;
var hasSkinIndices = skinIndices.length === vertices.length;
var hasSkinWeights = skinWeights.length === vertices.length;
if (vertices.length > 0 && faces.length === 0) {
console.error("THREE.DirectGeometry: Faceless geometries are not supported.");
}
for (var i2 = 0; i2 < faces.length; i2++) {
var face = faces[i2];
this.vertices.push(vertices[face.a], vertices[face.b], vertices[face.c]);
var vertexNormals = face.vertexNormals;
if (vertexNormals.length === 3) {
this.normals.push(vertexNormals[0], vertexNormals[1], vertexNormals[2]);
} else {
var normal = face.normal;
this.normals.push(normal, normal, normal);
}
var vertexColors = face.vertexColors;
if (vertexColors.length === 3) {
this.colors.push(vertexColors[0], vertexColors[1], vertexColors[2]);
} else {
var color = face.color;
this.colors.push(color, color, color);
}
if (hasFaceVertexUv === true) {
var vertexUvs = faceVertexUvs[0][i2];
if (vertexUvs !== void 0) {
this.uvs.push(vertexUvs[0], vertexUvs[1], vertexUvs[2]);
} else {
console.warn("THREE.DirectGeometry.fromGeometry(): Undefined vertexUv ", i2);
this.uvs.push(new Vector2(), new Vector2(), new Vector2());
}
}
if (hasFaceVertexUv2 === true) {
var vertexUvs = faceVertexUvs[1][i2];
if (vertexUvs !== void 0) {
this.uvs2.push(vertexUvs[0], vertexUvs[1], vertexUvs[2]);
} else {
console.warn("THREE.DirectGeometry.fromGeometry(): Undefined vertexUv2 ", i2);
this.uvs2.push(new Vector2(), new Vector2(), new Vector2());
}
}
for (var j = 0; j < morphTargetsLength; j++) {
var morphTarget = morphTargets[j].vertices;
morphTargetsPosition[j].data.push(morphTarget[face.a], morphTarget[face.b], morphTarget[face.c]);
}
for (var j = 0; j < morphNormalsLength; j++) {
var morphNormal = morphNormals[j].vertexNormals[i2];
morphTargetsNormal[j].data.push(morphNormal.a, morphNormal.b, morphNormal.c);
}
if (hasSkinIndices) {
this.skinIndices.push(skinIndices[face.a], skinIndices[face.b], skinIndices[face.c]);
}
if (hasSkinWeights) {
this.skinWeights.push(skinWeights[face.a], skinWeights[face.b], skinWeights[face.c]);
}
}
this.computeGroups(geometry);
this.verticesNeedUpdate = geometry.verticesNeedUpdate;
this.normalsNeedUpdate = geometry.normalsNeedUpdate;
this.colorsNeedUpdate = geometry.colorsNeedUpdate;
this.uvsNeedUpdate = geometry.uvsNeedUpdate;
this.groupsNeedUpdate = geometry.groupsNeedUpdate;
if (geometry.boundingSphere !== null) {
this.boundingSphere = geometry.boundingSphere.clone();
}
if (geometry.boundingBox !== null) {
this.boundingBox = geometry.boundingBox.clone();
}
return this;
}
});
function arrayMax(array) {
if (array.length === 0)
return -Infinity;
var max = array[0];
for (var i2 = 1, l = array.length; i2 < l; ++i2) {
if (array[i2] > max)
max = array[i2];
}
return max;
}
var _bufferGeometryId = 1;
var _m1$2 = new Matrix4();
var _obj = new Object3D();
var _offset = new Vector3();
var _box$2 = new Box3();
var _boxMorphTargets = new Box3();
var _vector$4 = new Vector3();
function BufferGeometry() {
Object.defineProperty(this, "id", { value: _bufferGeometryId += 2 });
this.uuid = MathUtils.generateUUID();
this.name = "";
this.type = "BufferGeometry";
this.index = null;
this.attributes = {};
this.morphAttributes = {};
this.morphTargetsRelative = false;
this.groups = [];
this.boundingBox = null;
this.boundingSphere = null;
this.drawRange = { start: 0, count: Infinity };
this.userData = {};
}
BufferGeometry.prototype = Object.assign(Object.create(EventDispatcher.prototype), {
constructor: BufferGeometry,
isBufferGeometry: true,
getIndex: function() {
return this.index;
},
setIndex: function(index) {
if (Array.isArray(index)) {
this.index = new (arrayMax(index) > 65535 ? Uint32BufferAttribute : Uint16BufferAttribute)(index, 1);
} else {
this.index = index;
}
},
getAttribute: function(name) {
return this.attributes[name];
},
setAttribute: function(name, attribute) {
this.attributes[name] = attribute;
return this;
},
deleteAttribute: function(name) {
delete this.attributes[name];
return this;
},
addGroup: function(start, count, materialIndex) {
this.groups.push({
start,
count,
materialIndex: materialIndex !== void 0 ? materialIndex : 0
});
},
clearGroups: function() {
this.groups = [];
},
setDrawRange: function(start, count) {
this.drawRange.start = start;
this.drawRange.count = count;
},
applyMatrix4: function(matrix) {
var position = this.attributes.position;
if (position !== void 0) {
position.applyMatrix4(matrix);
position.needsUpdate = true;
}
var normal = this.attributes.normal;
if (normal !== void 0) {
var normalMatrix = new Matrix3().getNormalMatrix(matrix);
normal.applyNormalMatrix(normalMatrix);
normal.needsUpdate = true;
}
var tangent = this.attributes.tangent;
if (tangent !== void 0) {
tangent.transformDirection(matrix);
tangent.needsUpdate = true;
}
if (this.boundingBox !== null) {
this.computeBoundingBox();
}
if (this.boundingSphere !== null) {
this.computeBoundingSphere();
}
return this;
},
rotateX: function(angle) {
_m1$2.makeRotationX(angle);
this.applyMatrix4(_m1$2);
return this;
},
rotateY: function(angle) {
_m1$2.makeRotationY(angle);
this.applyMatrix4(_m1$2);
return this;
},
rotateZ: function(angle) {
_m1$2.makeRotationZ(angle);
this.applyMatrix4(_m1$2);
return this;
},
translate: function(x, y, z) {
_m1$2.makeTranslation(x, y, z);
this.applyMatrix4(_m1$2);
return this;
},
scale: function(x, y, z) {
_m1$2.makeScale(x, y, z);
this.applyMatrix4(_m1$2);
return this;
},
lookAt: function(vector) {
_obj.lookAt(vector);
_obj.updateMatrix();
this.applyMatrix4(_obj.matrix);
return this;
},
center: function() {
this.computeBoundingBox();
this.boundingBox.getCenter(_offset).negate();
this.translate(_offset.x, _offset.y, _offset.z);
return this;
},
setFromObject: function(object) {
var geometry = object.geometry;
if (object.isPoints || object.isLine) {
var positions = new Float32BufferAttribute(geometry.vertices.length * 3, 3);
var colors = new Float32BufferAttribute(geometry.colors.length * 3, 3);
this.setAttribute("position", positions.copyVector3sArray(geometry.vertices));
this.setAttribute("color", colors.copyColorsArray(geometry.colors));
if (geometry.lineDistances && geometry.lineDistances.length === geometry.vertices.length) {
var lineDistances = new Float32BufferAttribute(geometry.lineDistances.length, 1);
this.setAttribute("lineDistance", lineDistances.copyArray(geometry.lineDistances));
}
if (geometry.boundingSphere !== null) {
this.boundingSphere = geometry.boundingSphere.clone();
}
if (geometry.boundingBox !== null) {
this.boundingBox = geometry.boundingBox.clone();
}
} else if (object.isMesh) {
if (geometry && geometry.isGeometry) {
this.fromGeometry(geometry);
}
}
return this;
},
setFromPoints: function(points) {
var position = [];
for (var i2 = 0, l = points.length; i2 < l; i2++) {
var point = points[i2];
position.push(point.x, point.y, point.z || 0);
}
this.setAttribute("position", new Float32BufferAttribute(position, 3));
return this;
},
updateFromObject: function(object) {
var geometry = object.geometry;
if (object.isMesh) {
var direct = geometry.__directGeometry;
if (geometry.elementsNeedUpdate === true) {
direct = void 0;
geometry.elementsNeedUpdate = false;
}
if (direct === void 0) {
return this.fromGeometry(geometry);
}
direct.verticesNeedUpdate = geometry.verticesNeedUpdate;
direct.normalsNeedUpdate = geometry.normalsNeedUpdate;
direct.colorsNeedUpdate = geometry.colorsNeedUpdate;
direct.uvsNeedUpdate = geometry.uvsNeedUpdate;
direct.groupsNeedUpdate = geometry.groupsNeedUpdate;
geometry.verticesNeedUpdate = false;
geometry.normalsNeedUpdate = false;
geometry.colorsNeedUpdate = false;
geometry.uvsNeedUpdate = false;
geometry.groupsNeedUpdate = false;
geometry = direct;
}
var attribute;
if (geometry.verticesNeedUpdate === true) {
attribute = this.attributes.position;
if (attribute !== void 0) {
attribute.copyVector3sArray(geometry.vertices);
attribute.needsUpdate = true;
}
geometry.verticesNeedUpdate = false;
}
if (geometry.normalsNeedUpdate === true) {
attribute = this.attributes.normal;
if (attribute !== void 0) {
attribute.copyVector3sArray(geometry.normals);
attribute.needsUpdate = true;
}
geometry.normalsNeedUpdate = false;
}
if (geometry.colorsNeedUpdate === true) {
attribute = this.attributes.color;
if (attribute !== void 0) {
attribute.copyColorsArray(geometry.colors);
attribute.needsUpdate = true;
}
geometry.colorsNeedUpdate = false;
}
if (geometry.uvsNeedUpdate) {
attribute = this.attributes.uv;
if (attribute !== void 0) {
attribute.copyVector2sArray(geometry.uvs);
attribute.needsUpdate = true;
}
geometry.uvsNeedUpdate = false;
}
if (geometry.lineDistancesNeedUpdate) {
attribute = this.attributes.lineDistance;
if (attribute !== void 0) {
attribute.copyArray(geometry.lineDistances);
attribute.needsUpdate = true;
}
geometry.lineDistancesNeedUpdate = false;
}
if (geometry.groupsNeedUpdate) {
geometry.computeGroups(object.geometry);
this.groups = geometry.groups;
geometry.groupsNeedUpdate = false;
}
return this;
},
fromGeometry: function(geometry) {
geometry.__directGeometry = new DirectGeometry().fromGeometry(geometry);
return this.fromDirectGeometry(geometry.__directGeometry);
},
fromDirectGeometry: function(geometry) {
var positions = new Float32Array(geometry.vertices.length * 3);
this.setAttribute("position", new BufferAttribute(positions, 3).copyVector3sArray(geometry.vertices));
if (geometry.normals.length > 0) {
var normals = new Float32Array(geometry.normals.length * 3);
this.setAttribute("normal", new BufferAttribute(normals, 3).copyVector3sArray(geometry.normals));
}
if (geometry.colors.length > 0) {
var colors = new Float32Array(geometry.colors.length * 3);
this.setAttribute("color", new BufferAttribute(colors, 3).copyColorsArray(geometry.colors));
}
if (geometry.uvs.length > 0) {
var uvs = new Float32Array(geometry.uvs.length * 2);
this.setAttribute("uv", new BufferAttribute(uvs, 2).copyVector2sArray(geometry.uvs));
}
if (geometry.uvs2.length > 0) {
var uvs2 = new Float32Array(geometry.uvs2.length * 2);
this.setAttribute("uv2", new BufferAttribute(uvs2, 2).copyVector2sArray(geometry.uvs2));
}
this.groups = geometry.groups;
for (var name in geometry.morphTargets) {
var array = [];
var morphTargets = geometry.morphTargets[name];
for (var i2 = 0, l = morphTargets.length; i2 < l; i2++) {
var morphTarget = morphTargets[i2];
var attribute = new Float32BufferAttribute(morphTarget.data.length * 3, 3);
attribute.name = morphTarget.name;
array.push(attribute.copyVector3sArray(morphTarget.data));
}
this.morphAttributes[name] = array;
}
if (geometry.skinIndices.length > 0) {
var skinIndices = new Float32BufferAttribute(geometry.skinIndices.length * 4, 4);
this.setAttribute("skinIndex", skinIndices.copyVector4sArray(geometry.skinIndices));
}
if (geometry.skinWeights.length > 0) {
var skinWeights = new Float32BufferAttribute(geometry.skinWeights.length * 4, 4);
this.setAttribute("skinWeight", skinWeights.copyVector4sArray(geometry.skinWeights));
}
if (geometry.boundingSphere !== null) {
this.boundingSphere = geometry.boundingSphere.clone();
}
if (geometry.boundingBox !== null) {
this.boundingBox = geometry.boundingBox.clone();
}
return this;
},
computeBoundingBox: function() {
if (this.boundingBox === null) {
this.boundingBox = new Box3();
}
var position = this.attributes.position;
var morphAttributesPosition = this.morphAttributes.position;
if (position !== void 0) {
this.boundingBox.setFromBufferAttribute(position);
if (morphAttributesPosition) {
for (var i2 = 0, il = morphAttributesPosition.length; i2 < il; i2++) {
var morphAttribute = morphAttributesPosition[i2];
_box$2.setFromBufferAttribute(morphAttribute);
if (this.morphTargetsRelative) {
_vector$4.addVectors(this.boundingBox.min, _box$2.min);
this.boundingBox.expandByPoint(_vector$4);
_vector$4.addVectors(this.boundingBox.max, _box$2.max);
this.boundingBox.expandByPoint(_vector$4);
} else {
this.boundingBox.expandByPoint(_box$2.min);
this.boundingBox.expandByPoint(_box$2.max);
}
}
}
} else {
this.boundingBox.makeEmpty();
}
if (isNaN(this.boundingBox.min.x) || isNaN(this.boundingBox.min.y) || isNaN(this.boundingBox.min.z)) {
console.error('THREE.BufferGeometry.computeBoundingBox: Computed min/max have NaN values. The "position" attribute is likely to have NaN values.', this);
}
},
computeBoundingSphere: function() {
if (this.boundingSphere === null) {
this.boundingSphere = new Sphere();
}
var position = this.attributes.position;
var morphAttributesPosition = this.morphAttributes.position;
if (position) {
var center = this.boundingSphere.center;
_box$2.setFromBufferAttribute(position);
if (morphAttributesPosition) {
for (var i2 = 0, il = morphAttributesPosition.length; i2 < il; i2++) {
var morphAttribute = morphAttributesPosition[i2];
_boxMorphTargets.setFromBufferAttribute(morphAttribute);
if (this.morphTargetsRelative) {
_vector$4.addVectors(_box$2.min, _boxMorphTargets.min);
_box$2.expandByPoint(_vector$4);
_vector$4.addVectors(_box$2.max, _boxMorphTargets.max);
_box$2.expandByPoint(_vector$4);
} else {
_box$2.expandByPoint(_boxMorphTargets.min);
_box$2.expandByPoint(_boxMorphTargets.max);
}
}
}
_box$2.getCenter(center);
var maxRadiusSq = 0;
for (var i2 = 0, il = position.count; i2 < il; i2++) {
_vector$4.fromBufferAttribute(position, i2);
maxRadiusSq = Math.max(maxRadiusSq, center.distanceToSquared(_vector$4));
}
if (morphAttributesPosition) {
for (var i2 = 0, il = morphAttributesPosition.length; i2 < il; i2++) {
var morphAttribute = morphAttributesPosition[i2];
var morphTargetsRelative = this.morphTargetsRelative;
for (var j = 0, jl = morphAttribute.count; j < jl; j++) {
_vector$4.fromBufferAttribute(morphAttribute, j);
if (morphTargetsRelative) {
_offset.fromBufferAttribute(position, j);
_vector$4.add(_offset);
}
maxRadiusSq = Math.max(maxRadiusSq, center.distanceToSquared(_vector$4));
}
}
}
this.boundingSphere.radius = Math.sqrt(maxRadiusSq);
if (isNaN(this.boundingSphere.radius)) {
console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.', this);
}
}
},
computeFaceNormals: function() {
},
computeVertexNormals: function() {
var index = this.index;
var attributes = this.attributes;
if (attributes.position) {
var positions = attributes.position.array;
if (attributes.normal === void 0) {
this.setAttribute("normal", new BufferAttribute(new Float32Array(positions.length), 3));
} else {
var array = attributes.normal.array;
for (var i2 = 0, il = array.length; i2 < il; i2++) {
array[i2] = 0;
}
}
var normals = attributes.normal.array;
var vA, vB, vC;
var pA = new Vector3(), pB = new Vector3(), pC = new Vector3();
var cb = new Vector3(), ab = new Vector3();
if (index) {
var indices = index.array;
for (var i2 = 0, il = index.count; i2 < il; i2 += 3) {
vA = indices[i2 + 0] * 3;
vB = indices[i2 + 1] * 3;
vC = indices[i2 + 2] * 3;
pA.fromArray(positions, vA);
pB.fromArray(positions, vB);
pC.fromArray(positions, vC);
cb.subVectors(pC, pB);
ab.subVectors(pA, pB);
cb.cross(ab);
normals[vA] += cb.x;
normals[vA + 1] += cb.y;
normals[vA + 2] += cb.z;
normals[vB] += cb.x;
normals[vB + 1] += cb.y;
normals[vB + 2] += cb.z;
normals[vC] += cb.x;
normals[vC + 1] += cb.y;
normals[vC + 2] += cb.z;
}
} else {
for (var i2 = 0, il = positions.length; i2 < il; i2 += 9) {
pA.fromArray(positions, i2);
pB.fromArray(positions, i2 + 3);
pC.fromArray(positions, i2 + 6);
cb.subVectors(pC, pB);
ab.subVectors(pA, pB);
cb.cross(ab);
normals[i2] = cb.x;
normals[i2 + 1] = cb.y;
normals[i2 + 2] = cb.z;
normals[i2 + 3] = cb.x;
normals[i2 + 4] = cb.y;
normals[i2 + 5] = cb.z;
normals[i2 + 6] = cb.x;
normals[i2 + 7] = cb.y;
normals[i2 + 8] = cb.z;
}
}
this.normalizeNormals();
attributes.normal.needsUpdate = true;
}
},
merge: function(geometry, offset) {
if (!(geometry && geometry.isBufferGeometry)) {
console.error("THREE.BufferGeometry.merge(): geometry not an instance of THREE.BufferGeometry.", geometry);
return;
}
if (offset === void 0) {
offset = 0;
console.warn(
"THREE.BufferGeometry.merge(): Overwriting original geometry, starting at offset=0. Use BufferGeometryUtils.mergeBufferGeometries() for lossless merge."
);
}
var attributes = this.attributes;
for (var key in attributes) {
if (geometry.attributes[key] === void 0)
continue;
var attribute1 = attributes[key];
var attributeArray1 = attribute1.array;
var attribute2 = geometry.attributes[key];
var attributeArray2 = attribute2.array;
var attributeOffset = attribute2.itemSize * offset;
var length = Math.min(attributeArray2.length, attributeArray1.length - attributeOffset);
for (var i2 = 0, j = attributeOffset; i2 < length; i2++, j++) {
attributeArray1[j] = attributeArray2[i2];
}
}
return this;
},
normalizeNormals: function() {
var normals = this.attributes.normal;
for (var i2 = 0, il = normals.count; i2 < il; i2++) {
_vector$4.x = normals.getX(i2);
_vector$4.y = normals.getY(i2);
_vector$4.z = normals.getZ(i2);
_vector$4.normalize();
normals.setXYZ(i2, _vector$4.x, _vector$4.y, _vector$4.z);
}
},
toNonIndexed: function() {
function convertBufferAttribute(attribute2, indices2) {
var array = attribute2.array;
var itemSize = attribute2.itemSize;
var array2 = new array.constructor(indices2.length * itemSize);
var index = 0, index2 = 0;
for (var i3 = 0, l2 = indices2.length; i3 < l2; i3++) {
index = indices2[i3] * itemSize;
for (var j = 0; j < itemSize; j++) {
array2[index2++] = array[index++];
}
}
return new BufferAttribute(array2, itemSize);
}
if (this.index === null) {
console.warn("THREE.BufferGeometry.toNonIndexed(): Geometry is already non-indexed.");
return this;
}
var geometry2 = new BufferGeometry();
var indices = this.index.array;
var attributes = this.attributes;
for (var name in attributes) {
var attribute = attributes[name];
var newAttribute = convertBufferAttribute(attribute, indices);
geometry2.setAttribute(name, newAttribute);
}
var morphAttributes = this.morphAttributes;
for (name in morphAttributes) {
var morphArray = [];
var morphAttribute = morphAttributes[name];
for (var i2 = 0, il = morphAttribute.length; i2 < il; i2++) {
var attribute = morphAttribute[i2];
var newAttribute = convertBufferAttribute(attribute, indices);
morphArray.push(newAttribute);
}
geometry2.morphAttributes[name] = morphArray;
}
geometry2.morphTargetsRelative = this.morphTargetsRelative;
var groups = this.groups;
for (var i2 = 0, l = groups.length; i2 < l; i2++) {
var group = groups[i2];
geometry2.addGroup(group.start, group.count, group.materialIndex);
}
return geometry2;
},
toJSON: function() {
var data = {
metadata: {
version: 4.5,
type: "BufferGeometry",
generator: "BufferGeometry.toJSON"
}
};
data.uuid = this.uuid;
data.type = this.type;
if (this.name !== "")
data.name = this.name;
if (Object.keys(this.userData).length > 0)
data.userData = this.userData;
if (this.parameters !== void 0) {
var parameters = this.parameters;
for (var key in parameters) {
if (parameters[key] !== void 0)
data[key] = parameters[key];
}
return data;
}
data.data = { attributes: {} };
var index = this.index;
if (index !== null) {
data.data.index = {
type: index.array.constructor.name,
array: Array.prototype.slice.call(index.array)
};
}
var attributes = this.attributes;
for (var key in attributes) {
var attribute = attributes[key];
var attributeData = attribute.toJSON();
if (attribute.name !== "")
attributeData.name = attribute.name;
data.data.attributes[key] = attributeData;
}
var morphAttributes = {};
var hasMorphAttributes = false;
for (var key in this.morphAttributes) {
var attributeArray = this.morphAttributes[key];
var array = [];
for (var i2 = 0, il = attributeArray.length; i2 < il; i2++) {
var attribute = attributeArray[i2];
var attributeData = attribute.toJSON();
if (attribute.name !== "")
attributeData.name = attribute.name;
array.push(attributeData);
}
if (array.length > 0) {
morphAttributes[key] = array;
hasMorphAttributes = true;
}
}
if (hasMorphAttributes) {
data.data.morphAttributes = morphAttributes;
data.data.morphTargetsRelative = this.morphTargetsRelative;
}
var groups = this.groups;
if (groups.length > 0) {
data.data.groups = JSON.parse(JSON.stringify(groups));
}
var boundingSphere = this.boundingSphere;
if (boundingSphere !== null) {
data.data.boundingSphere = {
center: boundingSphere.center.toArray(),
radius: boundingSphere.radius
};
}
return data;
},
clone: function() {
return new BufferGeometry().copy(this);
},
copy: function(source) {
var name, i2, l;
this.index = null;
this.attributes = {};
this.morphAttributes = {};
this.groups = [];
this.boundingBox = null;
this.boundingSphere = null;
this.name = source.name;
var index = source.index;
if (index !== null) {
this.setIndex(index.clone());
}
var attributes = source.attributes;
for (name in attributes) {
var attribute = attributes[name];
this.setAttribute(name, attribute.clone());
}
var morphAttributes = source.morphAttributes;
for (name in morphAttributes) {
var array = [];
var morphAttribute = morphAttributes[name];
for (i2 = 0, l = morphAttribute.length; i2 < l; i2++) {
array.push(morphAttribute[i2].clone());
}
this.morphAttributes[name] = array;
}
this.morphTargetsRelative = source.morphTargetsRelative;
var groups = source.groups;
for (i2 = 0, l = groups.length; i2 < l; i2++) {
var group = groups[i2];
this.addGroup(group.start, group.count, group.materialIndex);
}
var boundingBox = source.boundingBox;
if (boundingBox !== null) {
this.boundingBox = boundingBox.clone();
}
var boundingSphere = source.boundingSphere;
if (boundingSphere !== null) {
this.boundingSphere = boundingSphere.clone();
}
this.drawRange.start = source.drawRange.start;
this.drawRange.count = source.drawRange.count;
this.userData = source.userData;
return this;
},
dispose: function() {
this.dispatchEvent({ type: "dispose" });
}
});
var _inverseMatrix = new Matrix4();
var _ray = new Ray();
var _sphere = new Sphere();
var _vA = new Vector3();
var _vB = new Vector3();
var _vC = new Vector3();
var _tempA = new Vector3();
var _tempB = new Vector3();
var _tempC = new Vector3();
var _morphA = new Vector3();
var _morphB = new Vector3();
var _morphC = new Vector3();
var _uvA = new Vector2();
var _uvB = new Vector2();
var _uvC = new Vector2();
var _intersectionPoint = new Vector3();
var _intersectionPointWorld = new Vector3();
function Mesh(geometry, material) {
Object3D.call(this);
this.type = "Mesh";
this.geometry = geometry !== void 0 ? geometry : new BufferGeometry();
this.material = material !== void 0 ? material : new MeshBasicMaterial();
this.updateMorphTargets();
}
Mesh.prototype = Object.assign(Object.create(Object3D.prototype), {
constructor: Mesh,
isMesh: true,
copy: function(source) {
Object3D.prototype.copy.call(this, source);
if (source.morphTargetInfluences !== void 0) {
this.morphTargetInfluences = source.morphTargetInfluences.slice();
}
if (source.morphTargetDictionary !== void 0) {
this.morphTargetDictionary = Object.assign({}, source.morphTargetDictionary);
}
return this;
},
updateMorphTargets: function() {
var geometry = this.geometry;
var m, ml, name;
if (geometry.isBufferGeometry) {
var morphAttributes = geometry.morphAttributes;
var keys = Object.keys(morphAttributes);
if (keys.length > 0) {
var morphAttribute = morphAttributes[keys[0]];
if (morphAttribute !== void 0) {
this.morphTargetInfluences = [];
this.morphTargetDictionary = {};
for (m = 0, ml = morphAttribute.length; m < ml; m++) {
name = morphAttribute[m].name || String(m);
this.morphTargetInfluences.push(0);
this.morphTargetDictionary[name] = m;
}
}
}
} else {
var morphTargets = geometry.morphTargets;
if (morphTargets !== void 0 && morphTargets.length > 0) {
console.error("THREE.Mesh.updateMorphTargets() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.");
}
}
},
raycast: function(raycaster, intersects2) {
var geometry = this.geometry;
var material = this.material;
var matrixWorld = this.matrixWorld;
if (material === void 0)
return;
if (geometry.boundingSphere === null)
geometry.computeBoundingSphere();
_sphere.copy(geometry.boundingSphere);
_sphere.applyMatrix4(matrixWorld);
if (raycaster.ray.intersectsSphere(_sphere) === false)
return;
_inverseMatrix.getInverse(matrixWorld);
_ray.copy(raycaster.ray).applyMatrix4(_inverseMatrix);
if (geometry.boundingBox !== null) {
if (_ray.intersectsBox(geometry.boundingBox) === false)
return;
}
var intersection;
if (geometry.isBufferGeometry) {
var a, b, c;
var index = geometry.index;
var position = geometry.attributes.position;
var morphPosition = geometry.morphAttributes.position;
var morphTargetsRelative = geometry.morphTargetsRelative;
var uv = geometry.attributes.uv;
var uv2 = geometry.attributes.uv2;
var groups = geometry.groups;
var drawRange = geometry.drawRange;
var i2, j, il, jl;
var group, groupMaterial;
var start, end;
if (index !== null) {
if (Array.isArray(material)) {
for (i2 = 0, il = groups.length; i2 < il; i2++) {
group = groups[i2];
groupMaterial = material[group.materialIndex];
start = Math.max(group.start, drawRange.start);
end = Math.min(group.start + group.count, drawRange.start + drawRange.count);
for (j = start, jl = end; j < jl; j += 3) {
a = index.getX(j);
b = index.getX(j + 1);
c = index.getX(j + 2);
intersection = checkBufferGeometryIntersection(this, groupMaterial, raycaster, _ray, position, morphPosition, morphTargetsRelative, uv, uv2, a, b, c);
if (intersection) {
intersection.faceIndex = Math.floor(j / 3);
intersection.face.materialIndex = group.materialIndex;
intersects2.push(intersection);
}
}
}
} else {
start = Math.max(0, drawRange.start);
end = Math.min(index.count, drawRange.start + drawRange.count);
for (i2 = start, il = end; i2 < il; i2 += 3) {
a = index.getX(i2);
b = index.getX(i2 + 1);
c = index.getX(i2 + 2);
intersection = checkBufferGeometryIntersection(this, material, raycaster, _ray, position, morphPosition, morphTargetsRelative, uv, uv2, a, b, c);
if (intersection) {
intersection.faceIndex = Math.floor(i2 / 3);
intersects2.push(intersection);
}
}
}
} else if (position !== void 0) {
if (Array.isArray(material)) {
for (i2 = 0, il = groups.length; i2 < il; i2++) {
group = groups[i2];
groupMaterial = material[group.materialIndex];
start = Math.max(group.start, drawRange.start);
end = Math.min(group.start + group.count, drawRange.start + drawRange.count);
for (j = start, jl = end; j < jl; j += 3) {
a = j;
b = j + 1;
c = j + 2;
intersection = checkBufferGeometryIntersection(this, groupMaterial, raycaster, _ray, position, morphPosition, morphTargetsRelative, uv, uv2, a, b, c);
if (intersection) {
intersection.faceIndex = Math.floor(j / 3);
intersection.face.materialIndex = group.materialIndex;
intersects2.push(intersection);
}
}
}
} else {
start = Math.max(0, drawRange.start);
end = Math.min(position.count, drawRange.start + drawRange.count);
for (i2 = start, il = end; i2 < il; i2 += 3) {
a = i2;
b = i2 + 1;
c = i2 + 2;
intersection = checkBufferGeometryIntersection(this, material, raycaster, _ray, position, morphPosition, morphTargetsRelative, uv, uv2, a, b, c);
if (intersection) {
intersection.faceIndex = Math.floor(i2 / 3);
intersects2.push(intersection);
}
}
}
}
} else if (geometry.isGeometry) {
var fvA, fvB, fvC;
var isMultiMaterial = Array.isArray(material);
var vertices = geometry.vertices;
var faces = geometry.faces;
var uvs;
var faceVertexUvs = geometry.faceVertexUvs[0];
if (faceVertexUvs.length > 0)
uvs = faceVertexUvs;
for (var f = 0, fl = faces.length; f < fl; f++) {
var face = faces[f];
var faceMaterial = isMultiMaterial ? material[face.materialIndex] : material;
if (faceMaterial === void 0)
continue;
fvA = vertices[face.a];
fvB = vertices[face.b];
fvC = vertices[face.c];
intersection = checkIntersection(this, faceMaterial, raycaster, _ray, fvA, fvB, fvC, _intersectionPoint);
if (intersection) {
if (uvs && uvs[f]) {
var uvs_f = uvs[f];
_uvA.copy(uvs_f[0]);
_uvB.copy(uvs_f[1]);
_uvC.copy(uvs_f[2]);
intersection.uv = Triangle.getUV(_intersectionPoint, fvA, fvB, fvC, _uvA, _uvB, _uvC, new Vector2());
}
intersection.face = face;
intersection.faceIndex = f;
intersects2.push(intersection);
}
}
}
},
clone: function() {
return new this.constructor(this.geometry, this.material).copy(this);
}
});
function checkIntersection(object, material, raycaster, ray, pA, pB, pC, point) {
var intersect;
if (material.side === BackSide) {
intersect = ray.intersectTriangle(pC, pB, pA, true, point);
} else {
intersect = ray.intersectTriangle(pA, pB, pC, material.side !== DoubleSide, point);
}
if (intersect === null)
return null;
_intersectionPointWorld.copy(point);
_intersectionPointWorld.applyMatrix4(object.matrixWorld);
var distance = raycaster.ray.origin.distanceTo(_intersectionPointWorld);
if (distance < raycaster.near || distance > raycaster.far)
return null;
return {
distance,
point: _intersectionPointWorld.clone(),
object
};
}
function checkBufferGeometryIntersection(object, material, raycaster, ray, position, morphPosition, morphTargetsRelative, uv, uv2, a, b, c) {
_vA.fromBufferAttribute(position, a);
_vB.fromBufferAttribute(position, b);
_vC.fromBufferAttribute(position, c);
var morphInfluences = object.morphTargetInfluences;
if (material.morphTargets && morphPosition && morphInfluences) {
_morphA.set(0, 0, 0);
_morphB.set(0, 0, 0);
_morphC.set(0, 0, 0);
for (var i2 = 0, il = morphPosition.length; i2 < il; i2++) {
var influence = morphInfluences[i2];
var morphAttribute = morphPosition[i2];
if (influence === 0)
continue;
_tempA.fromBufferAttribute(morphAttribute, a);
_tempB.fromBufferAttribute(morphAttribute, b);
_tempC.fromBufferAttribute(morphAttribute, c);
if (morphTargetsRelative) {
_morphA.addScaledVector(_tempA, influence);
_morphB.addScaledVector(_tempB, influence);
_morphC.addScaledVector(_tempC, influence);
} else {
_morphA.addScaledVector(_tempA.sub(_vA), influence);
_morphB.addScaledVector(_tempB.sub(_vB), influence);
_morphC.addScaledVector(_tempC.sub(_vC), influence);
}
}
_vA.add(_morphA);
_vB.add(_morphB);
_vC.add(_morphC);
}
var intersection = checkIntersection(object, material, raycaster, ray, _vA, _vB, _vC, _intersectionPoint);
if (intersection) {
if (uv) {
_uvA.fromBufferAttribute(uv, a);
_uvB.fromBufferAttribute(uv, b);
_uvC.fromBufferAttribute(uv, c);
intersection.uv = Triangle.getUV(_intersectionPoint, _vA, _vB, _vC, _uvA, _uvB, _uvC, new Vector2());
}
if (uv2) {
_uvA.fromBufferAttribute(uv2, a);
_uvB.fromBufferAttribute(uv2, b);
_uvC.fromBufferAttribute(uv2, c);
intersection.uv2 = Triangle.getUV(_intersectionPoint, _vA, _vB, _vC, _uvA, _uvB, _uvC, new Vector2());
}
var face = new Face3(a, b, c);
Triangle.getNormal(_vA, _vB, _vC, face.normal);
intersection.face = face;
}
return intersection;
}
var _geometryId = 0;
var _m1$3 = new Matrix4();
var _obj$1 = new Object3D();
var _offset$1 = new Vector3();
function Geometry() {
Object.defineProperty(this, "id", { value: _geometryId += 2 });
this.uuid = MathUtils.generateUUID();
this.name = "";
this.type = "Geometry";
this.vertices = [];
this.colors = [];
this.faces = [];
this.faceVertexUvs = [[]];
this.morphTargets = [];
this.morphNormals = [];
this.skinWeights = [];
this.skinIndices = [];
this.lineDistances = [];
this.boundingBox = null;
this.boundingSphere = null;
this.elementsNeedUpdate = false;
this.verticesNeedUpdate = false;
this.uvsNeedUpdate = false;
this.normalsNeedUpdate = false;
this.colorsNeedUpdate = false;
this.lineDistancesNeedUpdate = false;
this.groupsNeedUpdate = false;
}
Geometry.prototype = Object.assign(Object.create(EventDispatcher.prototype), {
constructor: Geometry,
isGeometry: true,
applyMatrix4: function(matrix) {
var normalMatrix = new Matrix3().getNormalMatrix(matrix);
for (var i2 = 0, il = this.vertices.length; i2 < il; i2++) {
var vertex = this.vertices[i2];
vertex.applyMatrix4(matrix);
}
for (var i2 = 0, il = this.faces.length; i2 < il; i2++) {
var face = this.faces[i2];
face.normal.applyMatrix3(normalMatrix).normalize();
for (var j = 0, jl = face.vertexNormals.length; j < jl; j++) {
face.vertexNormals[j].applyMatrix3(normalMatrix).normalize();
}
}
if (this.boundingBox !== null) {
this.computeBoundingBox();
}
if (this.boundingSphere !== null) {
this.computeBoundingSphere();
}
this.verticesNeedUpdate = true;
this.normalsNeedUpdate = true;
return this;
},
rotateX: function(angle) {
_m1$3.makeRotationX(angle);
this.applyMatrix4(_m1$3);
return this;
},
rotateY: function(angle) {
_m1$3.makeRotationY(angle);
this.applyMatrix4(_m1$3);
return this;
},
rotateZ: function(angle) {
_m1$3.makeRotationZ(angle);
this.applyMatrix4(_m1$3);
return this;
},
translate: function(x, y, z) {
_m1$3.makeTranslation(x, y, z);
this.applyMatrix4(_m1$3);
return this;
},
scale: function(x, y, z) {
_m1$3.makeScale(x, y, z);
this.applyMatrix4(_m1$3);
return this;
},
lookAt: function(vector) {
_obj$1.lookAt(vector);
_obj$1.updateMatrix();
this.applyMatrix4(_obj$1.matrix);
return this;
},
fromBufferGeometry: function(geometry) {
var scope = this;
var indices = geometry.index !== null ? geometry.index.array : void 0;
var attributes = geometry.attributes;
if (attributes.position === void 0) {
console.error("THREE.Geometry.fromBufferGeometry(): Position attribute required for conversion.");
return this;
}
var positions = attributes.position.array;
var normals = attributes.normal !== void 0 ? attributes.normal.array : void 0;
var colors = attributes.color !== void 0 ? attributes.color.array : void 0;
var uvs = attributes.uv !== void 0 ? attributes.uv.array : void 0;
var uvs2 = attributes.uv2 !== void 0 ? attributes.uv2.array : void 0;
if (uvs2 !== void 0)
this.faceVertexUvs[1] = [];
for (var i2 = 0; i2 < positions.length; i2 += 3) {
scope.vertices.push(new Vector3().fromArray(positions, i2));
if (colors !== void 0) {
scope.colors.push(new Color().fromArray(colors, i2));
}
}
function addFace(a, b, c, materialIndex) {
var vertexColors = colors === void 0 ? [] : [
scope.colors[a].clone(),
scope.colors[b].clone(),
scope.colors[c].clone()
];
var vertexNormals = normals === void 0 ? [] : [
new Vector3().fromArray(normals, a * 3),
new Vector3().fromArray(normals, b * 3),
new Vector3().fromArray(normals, c * 3)
];
var face = new Face3(a, b, c, vertexNormals, vertexColors, materialIndex);
scope.faces.push(face);
if (uvs !== void 0) {
scope.faceVertexUvs[0].push([
new Vector2().fromArray(uvs, a * 2),
new Vector2().fromArray(uvs, b * 2),
new Vector2().fromArray(uvs, c * 2)
]);
}
if (uvs2 !== void 0) {
scope.faceVertexUvs[1].push([
new Vector2().fromArray(uvs2, a * 2),
new Vector2().fromArray(uvs2, b * 2),
new Vector2().fromArray(uvs2, c * 2)
]);
}
}
var groups = geometry.groups;
if (groups.length > 0) {
for (var i2 = 0; i2 < groups.length; i2++) {
var group = groups[i2];
var start = group.start;
var count = group.count;
for (var j = start, jl = start + count; j < jl; j += 3) {
if (indices !== void 0) {
addFace(indices[j], indices[j + 1], indices[j + 2], group.materialIndex);
} else {
addFace(j, j + 1, j + 2, group.materialIndex);
}
}
}
} else {
if (indices !== void 0) {
for (var i2 = 0; i2 < indices.length; i2 += 3) {
addFace(indices[i2], indices[i2 + 1], indices[i2 + 2]);
}
} else {
for (var i2 = 0; i2 < positions.length / 3; i2 += 3) {
addFace(i2, i2 + 1, i2 + 2);
}
}
}
this.computeFaceNormals();
if (geometry.boundingBox !== null) {
this.boundingBox = geometry.boundingBox.clone();
}
if (geometry.boundingSphere !== null) {
this.boundingSphere = geometry.boundingSphere.clone();
}
return this;
},
center: function() {
this.computeBoundingBox();
this.boundingBox.getCenter(_offset$1).negate();
this.translate(_offset$1.x, _offset$1.y, _offset$1.z);
return this;
},
normalize: function() {
this.computeBoundingSphere();
var center = this.boundingSphere.center;
var radius = this.boundingSphere.radius;
var s = radius === 0 ? 1 : 1 / radius;
var matrix = new Matrix4();
matrix.set(
s,
0,
0,
-s * center.x,
0,
s,
0,
-s * center.y,
0,
0,
s,
-s * center.z,
0,
0,
0,
1
);
this.applyMatrix4(matrix);
return this;
},
computeFaceNormals: function() {
var cb = new Vector3(), ab = new Vector3();
for (var f = 0, fl = this.faces.length; f < fl; f++) {
var face = this.faces[f];
var vA = this.vertices[face.a];
var vB = this.vertices[face.b];
var vC = this.vertices[face.c];
cb.subVectors(vC, vB);
ab.subVectors(vA, vB);
cb.cross(ab);
cb.normalize();
face.normal.copy(cb);
}
},
computeVertexNormals: function(areaWeighted) {
if (areaWeighted === void 0)
areaWeighted = true;
var v, vl, f, fl, face, vertices;
vertices = new Array(this.vertices.length);
for (v = 0, vl = this.vertices.length; v < vl; v++) {
vertices[v] = new Vector3();
}
if (areaWeighted) {
var vA, vB, vC;
var cb = new Vector3(), ab = new Vector3();
for (f = 0, fl = this.faces.length; f < fl; f++) {
face = this.faces[f];
vA = this.vertices[face.a];
vB = this.vertices[face.b];
vC = this.vertices[face.c];
cb.subVectors(vC, vB);
ab.subVectors(vA, vB);
cb.cross(ab);
vertices[face.a].add(cb);
vertices[face.b].add(cb);
vertices[face.c].add(cb);
}
} else {
this.computeFaceNormals();
for (f = 0, fl = this.faces.length; f < fl; f++) {
face = this.faces[f];
vertices[face.a].add(face.normal);
vertices[face.b].add(face.normal);
vertices[face.c].add(face.normal);
}
}
for (v = 0, vl = this.vertices.length; v < vl; v++) {
vertices[v].normalize();
}
for (f = 0, fl = this.faces.length; f < fl; f++) {
face = this.faces[f];
var vertexNormals = face.vertexNormals;
if (vertexNormals.length === 3) {
vertexNormals[0].copy(vertices[face.a]);
vertexNormals[1].copy(vertices[face.b]);
vertexNormals[2].copy(vertices[face.c]);
} else {
vertexNormals[0] = vertices[face.a].clone();
vertexNormals[1] = vertices[face.b].clone();
vertexNormals[2] = vertices[face.c].clone();
}
}
if (this.faces.length > 0) {
this.normalsNeedUpdate = true;
}
},
computeFlatVertexNormals: function() {
var f, fl, face;
this.computeFaceNormals();
for (f = 0, fl = this.faces.length; f < fl; f++) {
face = this.faces[f];
var vertexNormals = face.vertexNormals;
if (vertexNormals.length === 3) {
vertexNormals[0].copy(face.normal);
vertexNormals[1].copy(face.normal);
vertexNormals[2].copy(face.normal);
} else {
vertexNormals[0] = face.normal.clone();
vertexNormals[1] = face.normal.clone();
vertexNormals[2] = face.normal.clone();
}
}
if (this.faces.length > 0) {
this.normalsNeedUpdate = true;
}
},
computeMorphNormals: function() {
var i2, il, f, fl, face;
for (f = 0, fl = this.faces.length; f < fl; f++) {
face = this.faces[f];
if (!face.__originalFaceNormal) {
face.__originalFaceNormal = face.normal.clone();
} else {
face.__originalFaceNormal.copy(face.normal);
}
if (!face.__originalVertexNormals)
face.__originalVertexNormals = [];
for (i2 = 0, il = face.vertexNormals.length; i2 < il; i2++) {
if (!face.__originalVertexNormals[i2]) {
face.__originalVertexNormals[i2] = face.vertexNormals[i2].clone();
} else {
face.__originalVertexNormals[i2].copy(face.vertexNormals[i2]);
}
}
}
var tmpGeo = new Geometry();
tmpGeo.faces = this.faces;
for (i2 = 0, il = this.morphTargets.length; i2 < il; i2++) {
if (!this.morphNormals[i2]) {
this.morphNormals[i2] = {};
this.morphNormals[i2].faceNormals = [];
this.morphNormals[i2].vertexNormals = [];
var dstNormalsFace = this.morphNormals[i2].faceNormals;
var dstNormalsVertex = this.morphNormals[i2].vertexNormals;
var faceNormal, vertexNormals;
for (f = 0, fl = this.faces.length; f < fl; f++) {
faceNormal = new Vector3();
vertexNormals = { a: new Vector3(), b: new Vector3(), c: new Vector3() };
dstNormalsFace.push(faceNormal);
dstNormalsVertex.push(vertexNormals);
}
}
var morphNormals = this.morphNormals[i2];
tmpGeo.vertices = this.morphTargets[i2].vertices;
tmpGeo.computeFaceNormals();
tmpGeo.computeVertexNormals();
var faceNormal, vertexNormals;
for (f = 0, fl = this.faces.length; f < fl; f++) {
face = this.faces[f];
faceNormal = morphNormals.faceNormals[f];
vertexNormals = morphNormals.vertexNormals[f];
faceNormal.copy(face.normal);
vertexNormals.a.copy(face.vertexNormals[0]);
vertexNormals.b.copy(face.vertexNormals[1]);
vertexNormals.c.copy(face.vertexNormals[2]);
}
}
for (f = 0, fl = this.faces.length; f < fl; f++) {
face = this.faces[f];
face.normal = face.__originalFaceNormal;
face.vertexNormals = face.__originalVertexNormals;
}
},
computeBoundingBox: function() {
if (this.boundingBox === null) {
this.boundingBox = new Box3();
}
this.boundingBox.setFromPoints(this.vertices);
},
computeBoundingSphere: function() {
if (this.boundingSphere === null) {
this.boundingSphere = new Sphere();
}
this.boundingSphere.setFromPoints(this.vertices);
},
merge: function(geometry, matrix, materialIndexOffset) {
if (!(geometry && geometry.isGeometry)) {
console.error("THREE.Geometry.merge(): geometry not an instance of THREE.Geometry.", geometry);
return;
}
var normalMatrix, vertexOffset = this.vertices.length, vertices1 = this.vertices, vertices2 = geometry.vertices, faces1 = this.faces, faces2 = geometry.faces, colors1 = this.colors, colors2 = geometry.colors;
if (materialIndexOffset === void 0)
materialIndexOffset = 0;
if (matrix !== void 0) {
normalMatrix = new Matrix3().getNormalMatrix(matrix);
}
for (var i2 = 0, il = vertices2.length; i2 < il; i2++) {
var vertex = vertices2[i2];
var vertexCopy = vertex.clone();
if (matrix !== void 0)
vertexCopy.applyMatrix4(matrix);
vertices1.push(vertexCopy);
}
for (var i2 = 0, il = colors2.length; i2 < il; i2++) {
colors1.push(colors2[i2].clone());
}
for (i2 = 0, il = faces2.length; i2 < il; i2++) {
var face = faces2[i2], faceCopy, normal, color, faceVertexNormals = face.vertexNormals, faceVertexColors = face.vertexColors;
faceCopy = new Face3(face.a + vertexOffset, face.b + vertexOffset, face.c + vertexOffset);
faceCopy.normal.copy(face.normal);
if (normalMatrix !== void 0) {
faceCopy.normal.applyMatrix3(normalMatrix).normalize();
}
for (var j = 0, jl = faceVertexNormals.length; j < jl; j++) {
normal = faceVertexNormals[j].clone();
if (normalMatrix !== void 0) {
normal.applyMatrix3(normalMatrix).normalize();
}
faceCopy.vertexNormals.push(normal);
}
faceCopy.color.copy(face.color);
for (var j = 0, jl = faceVertexColors.length; j < jl; j++) {
color = faceVertexColors[j];
faceCopy.vertexColors.push(color.clone());
}
faceCopy.materialIndex = face.materialIndex + materialIndexOffset;
faces1.push(faceCopy);
}
for (var i2 = 0, il = geometry.faceVertexUvs.length; i2 < il; i2++) {
var faceVertexUvs2 = geometry.faceVertexUvs[i2];
if (this.faceVertexUvs[i2] === void 0)
this.faceVertexUvs[i2] = [];
for (var j = 0, jl = faceVertexUvs2.length; j < jl; j++) {
var uvs2 = faceVertexUvs2[j], uvsCopy = [];
for (var k = 0, kl = uvs2.length; k < kl; k++) {
uvsCopy.push(uvs2[k].clone());
}
this.faceVertexUvs[i2].push(uvsCopy);
}
}
},
mergeMesh: function(mesh) {
if (!(mesh && mesh.isMesh)) {
console.error("THREE.Geometry.mergeMesh(): mesh not an instance of THREE.Mesh.", mesh);
return;
}
if (mesh.matrixAutoUpdate)
mesh.updateMatrix();
this.merge(mesh.geometry, mesh.matrix);
},
/*
* Checks for duplicate vertices with hashmap.
* Duplicated vertices are removed
* and faces' vertices are updated.
*/
mergeVertices: function() {
var verticesMap = {};
var unique = [], changes = [];
var v, key;
var precisionPoints = 4;
var precision = Math.pow(10, precisionPoints);
var i2, il, face;
var indices, j, jl;
for (i2 = 0, il = this.vertices.length; i2 < il; i2++) {
v = this.vertices[i2];
key = Math.round(v.x * precision) + "_" + Math.round(v.y * precision) + "_" + Math.round(v.z * precision);
if (verticesMap[key] === void 0) {
verticesMap[key] = i2;
unique.push(this.vertices[i2]);
changes[i2] = unique.length - 1;
} else {
changes[i2] = changes[verticesMap[key]];
}
}
var faceIndicesToRemove = [];
for (i2 = 0, il = this.faces.length; i2 < il; i2++) {
face = this.faces[i2];
face.a = changes[face.a];
face.b = changes[face.b];
face.c = changes[face.c];
indices = [face.a, face.b, face.c];
for (var n = 0; n < 3; n++) {
if (indices[n] === indices[(n + 1) % 3]) {
faceIndicesToRemove.push(i2);
break;
}
}
}
for (i2 = faceIndicesToRemove.length - 1; i2 >= 0; i2--) {
var idx = faceIndicesToRemove[i2];
this.faces.splice(idx, 1);
for (j = 0, jl = this.faceVertexUvs.length; j < jl; j++) {
this.faceVertexUvs[j].splice(idx, 1);
}
}
var diff = this.vertices.length - unique.length;
this.vertices = unique;
return diff;
},
setFromPoints: function(points) {
this.vertices = [];
for (var i2 = 0, l = points.length; i2 < l; i2++) {
var point = points[i2];
this.vertices.push(new Vector3(point.x, point.y, point.z || 0));
}
return this;
},
sortFacesByMaterialIndex: function() {
var faces = this.faces;
var length = faces.length;
for (var i2 = 0; i2 < length; i2++) {
faces[i2]._id = i2;
}
function materialIndexSort(a, b) {
return a.materialIndex - b.materialIndex;
}
faces.sort(materialIndexSort);
var uvs1 = this.faceVertexUvs[0];
var uvs2 = this.faceVertexUvs[1];
var newUvs1, newUvs2;
if (uvs1 && uvs1.length === length)
newUvs1 = [];
if (uvs2 && uvs2.length === length)
newUvs2 = [];
for (var i2 = 0; i2 < length; i2++) {
var id = faces[i2]._id;
if (newUvs1)
newUvs1.push(uvs1[id]);
if (newUvs2)
newUvs2.push(uvs2[id]);
}
if (newUvs1)
this.faceVertexUvs[0] = newUvs1;
if (newUvs2)
this.faceVertexUvs[1] = newUvs2;
},
toJSON: function() {
var data = {
metadata: {
version: 4.5,
type: "Geometry",
generator: "Geometry.toJSON"
}
};
data.uuid = this.uuid;
data.type = this.type;
if (this.name !== "")
data.name = this.name;
if (this.parameters !== void 0) {
var parameters = this.parameters;
for (var key in parameters) {
if (parameters[key] !== void 0)
data[key] = parameters[key];
}
return data;
}
var vertices = [];
for (var i2 = 0; i2 < this.vertices.length; i2++) {
var vertex = this.vertices[i2];
vertices.push(vertex.x, vertex.y, vertex.z);
}
var faces = [];
var normals = [];
var normalsHash = {};
var colors = [];
var colorsHash = {};
var uvs = [];
var uvsHash = {};
for (var i2 = 0; i2 < this.faces.length; i2++) {
var face = this.faces[i2];
var hasMaterial = true;
var hasFaceUv = false;
var hasFaceVertexUv = this.faceVertexUvs[0][i2] !== void 0;
var hasFaceNormal = face.normal.length() > 0;
var hasFaceVertexNormal = face.vertexNormals.length > 0;
var hasFaceColor = face.color.r !== 1 || face.color.g !== 1 || face.color.b !== 1;
var hasFaceVertexColor = face.vertexColors.length > 0;
var faceType = 0;
faceType = setBit(faceType, 0, 0);
faceType = setBit(faceType, 1, hasMaterial);
faceType = setBit(faceType, 2, hasFaceUv);
faceType = setBit(faceType, 3, hasFaceVertexUv);
faceType = setBit(faceType, 4, hasFaceNormal);
faceType = setBit(faceType, 5, hasFaceVertexNormal);
faceType = setBit(faceType, 6, hasFaceColor);
faceType = setBit(faceType, 7, hasFaceVertexColor);
faces.push(faceType);
faces.push(face.a, face.b, face.c);
faces.push(face.materialIndex);
if (hasFaceVertexUv) {
var faceVertexUvs = this.faceVertexUvs[0][i2];
faces.push(
getUvIndex(faceVertexUvs[0]),
getUvIndex(faceVertexUvs[1]),
getUvIndex(faceVertexUvs[2])
);
}
if (hasFaceNormal) {
faces.push(getNormalIndex(face.normal));
}
if (hasFaceVertexNormal) {
var vertexNormals = face.vertexNormals;
faces.push(
getNormalIndex(vertexNormals[0]),
getNormalIndex(vertexNormals[1]),
getNormalIndex(vertexNormals[2])
);
}
if (hasFaceColor) {
faces.push(getColorIndex(face.color));
}
if (hasFaceVertexColor) {
var vertexColors = face.vertexColors;
faces.push(
getColorIndex(vertexColors[0]),
getColorIndex(vertexColors[1]),
getColorIndex(vertexColors[2])
);
}
}
function setBit(value, position, enabled) {
return enabled ? value | 1 << position : value & ~(1 << position);
}
function getNormalIndex(normal) {
var hash = normal.x.toString() + normal.y.toString() + normal.z.toString();
if (normalsHash[hash] !== void 0) {
return normalsHash[hash];
}
normalsHash[hash] = normals.length / 3;
normals.push(normal.x, normal.y, normal.z);
return normalsHash[hash];
}
function getColorIndex(color) {
var hash = color.r.toString() + color.g.toString() + color.b.toString();
if (colorsHash[hash] !== void 0) {
return colorsHash[hash];
}
colorsHash[hash] = colors.length;
colors.push(color.getHex());
return colorsHash[hash];
}
function getUvIndex(uv) {
var hash = uv.x.toString() + uv.y.toString();
if (uvsHash[hash] !== void 0) {
return uvsHash[hash];
}
uvsHash[hash] = uvs.length / 2;
uvs.push(uv.x, uv.y);
return uvsHash[hash];
}
data.data = {};
data.data.vertices = vertices;
data.data.normals = normals;
if (colors.length > 0)
data.data.colors = colors;
if (uvs.length > 0)
data.data.uvs = [uvs];
data.data.faces = faces;
return data;
},
clone: function() {
return new Geometry().copy(this);
},
copy: function(source) {
var i2, il, j, jl, k, kl;
this.vertices = [];
this.colors = [];
this.faces = [];
this.faceVertexUvs = [[]];
this.morphTargets = [];
this.morphNormals = [];
this.skinWeights = [];
this.skinIndices = [];
this.lineDistances = [];
this.boundingBox = null;
this.boundingSphere = null;
this.name = source.name;
var vertices = source.vertices;
for (i2 = 0, il = vertices.length; i2 < il; i2++) {
this.vertices.push(vertices[i2].clone());
}
var colors = source.colors;
for (i2 = 0, il = colors.length; i2 < il; i2++) {
this.colors.push(colors[i2].clone());
}
var faces = source.faces;
for (i2 = 0, il = faces.length; i2 < il; i2++) {
this.faces.push(faces[i2].clone());
}
for (i2 = 0, il = source.faceVertexUvs.length; i2 < il; i2++) {
var faceVertexUvs = source.faceVertexUvs[i2];
if (this.faceVertexUvs[i2] === void 0) {
this.faceVertexUvs[i2] = [];
}
for (j = 0, jl = faceVertexUvs.length; j < jl; j++) {
var uvs = faceVertexUvs[j], uvsCopy = [];
for (k = 0, kl = uvs.length; k < kl; k++) {
var uv = uvs[k];
uvsCopy.push(uv.clone());
}
this.faceVertexUvs[i2].push(uvsCopy);
}
}
var morphTargets = source.morphTargets;
for (i2 = 0, il = morphTargets.length; i2 < il; i2++) {
var morphTarget = {};
morphTarget.name = morphTargets[i2].name;
if (morphTargets[i2].vertices !== void 0) {
morphTarget.vertices = [];
for (j = 0, jl = morphTargets[i2].vertices.length; j < jl; j++) {
morphTarget.vertices.push(morphTargets[i2].vertices[j].clone());
}
}
if (morphTargets[i2].normals !== void 0) {
morphTarget.normals = [];
for (j = 0, jl = morphTargets[i2].normals.length; j < jl; j++) {
morphTarget.normals.push(morphTargets[i2].normals[j].clone());
}
}
this.morphTargets.push(morphTarget);
}
var morphNormals = source.morphNormals;
for (i2 = 0, il = morphNormals.length; i2 < il; i2++) {
var morphNormal = {};
if (morphNormals[i2].vertexNormals !== void 0) {
morphNormal.vertexNormals = [];
for (j = 0, jl = morphNormals[i2].vertexNormals.length; j < jl; j++) {
var srcVertexNormal = morphNormals[i2].vertexNormals[j];
var destVertexNormal = {};
destVertexNormal.a = srcVertexNormal.a.clone();
destVertexNormal.b = srcVertexNormal.b.clone();
destVertexNormal.c = srcVertexNormal.c.clone();
morphNormal.vertexNormals.push(destVertexNormal);
}
}
if (morphNormals[i2].faceNormals !== void 0) {
morphNormal.faceNormals = [];
for (j = 0, jl = morphNormals[i2].faceNormals.length; j < jl; j++) {
morphNormal.faceNormals.push(morphNormals[i2].faceNormals[j].clone());
}
}
this.morphNormals.push(morphNormal);
}
var skinWeights = source.skinWeights;
for (i2 = 0, il = skinWeights.length; i2 < il; i2++) {
this.skinWeights.push(skinWeights[i2].clone());
}
var skinIndices = source.skinIndices;
for (i2 = 0, il = skinIndices.length; i2 < il; i2++) {
this.skinIndices.push(skinIndices[i2].clone());
}
var lineDistances = source.lineDistances;
for (i2 = 0, il = lineDistances.length; i2 < il; i2++) {
this.lineDistances.push(lineDistances[i2]);
}
var boundingBox = source.boundingBox;
if (boundingBox !== null) {
this.boundingBox = boundingBox.clone();
}
var boundingSphere = source.boundingSphere;
if (boundingSphere !== null) {
this.boundingSphere = boundingSphere.clone();
}
this.elementsNeedUpdate = source.elementsNeedUpdate;
this.verticesNeedUpdate = source.verticesNeedUpdate;
this.uvsNeedUpdate = source.uvsNeedUpdate;
this.normalsNeedUpdate = source.normalsNeedUpdate;
this.colorsNeedUpdate = source.colorsNeedUpdate;
this.lineDistancesNeedUpdate = source.lineDistancesNeedUpdate;
this.groupsNeedUpdate = source.groupsNeedUpdate;
return this;
},
dispose: function() {
this.dispatchEvent({ type: "dispose" });
}
});
class BoxGeometry extends Geometry {
constructor(width, height, depth, widthSegments, heightSegments, depthSegments) {
super();
this.type = "BoxGeometry";
this.parameters = {
width,
height,
depth,
widthSegments,
heightSegments,
depthSegments
};
this.fromBufferGeometry(new BoxBufferGeometry(width, height, depth, widthSegments, heightSegments, depthSegments));
this.mergeVertices();
}
}
class BoxBufferGeometry extends BufferGeometry {
constructor(width, height, depth, widthSegments, heightSegments, depthSegments) {
super();
this.type = "BoxBufferGeometry";
this.parameters = {
width,
height,
depth,
widthSegments,
heightSegments,
depthSegments
};
var scope = this;
width = width || 1;
height = height || 1;
depth = depth || 1;
widthSegments = Math.floor(widthSegments) || 1;
heightSegments = Math.floor(heightSegments) || 1;
depthSegments = Math.floor(depthSegments) || 1;
var indices = [];
var vertices = [];
var normals = [];
var uvs = [];
var numberOfVertices = 0;
var groupStart = 0;
buildPlane("z", "y", "x", -1, -1, depth, height, width, depthSegments, heightSegments, 0);
buildPlane("z", "y", "x", 1, -1, depth, height, -width, depthSegments, heightSegments, 1);
buildPlane("x", "z", "y", 1, 1, width, depth, height, widthSegments, depthSegments, 2);
buildPlane("x", "z", "y", 1, -1, width, depth, -height, widthSegments, depthSegments, 3);
buildPlane("x", "y", "z", 1, -1, width, height, depth, widthSegments, heightSegments, 4);
buildPlane("x", "y", "z", -1, -1, width, height, -depth, widthSegments, heightSegments, 5);
this.setIndex(indices);
this.setAttribute("position", new Float32BufferAttribute(vertices, 3));
this.setAttribute("normal", new Float32BufferAttribute(normals, 3));
this.setAttribute("uv", new Float32BufferAttribute(uvs, 2));
function buildPlane(u, v, w, udir, vdir, width2, height2, depth2, gridX, gridY, materialIndex) {
var segmentWidth = width2 / gridX;
var segmentHeight = height2 / gridY;
var widthHalf = width2 / 2;
var heightHalf = height2 / 2;
var depthHalf = depth2 / 2;
var gridX1 = gridX + 1;
var gridY1 = gridY + 1;
var vertexCounter = 0;
var groupCount = 0;
var ix, iy;
var vector = new Vector3();
for (iy = 0; iy < gridY1; iy++) {
var y = iy * segmentHeight - heightHalf;
for (ix = 0; ix < gridX1; ix++) {
var x = ix * segmentWidth - widthHalf;
vector[u] = x * udir;
vector[v] = y * vdir;
vector[w] = depthHalf;
vertices.push(vector.x, vector.y, vector.z);
vector[u] = 0;
vector[v] = 0;
vector[w] = depth2 > 0 ? 1 : -1;
normals.push(vector.x, vector.y, vector.z);
uvs.push(ix / gridX);
uvs.push(1 - iy / gridY);
vertexCounter += 1;
}
}
for (iy = 0; iy < gridY; iy++) {
for (ix = 0; ix < gridX; ix++) {
var a = numberOfVertices + ix + gridX1 * iy;
var b = numberOfVertices + ix + gridX1 * (iy + 1);
var c = numberOfVertices + (ix + 1) + gridX1 * (iy + 1);
var d = numberOfVertices + (ix + 1) + gridX1 * iy;
indices.push(a, b, d);
indices.push(b, c, d);
groupCount += 6;
}
}
scope.addGroup(groupStart, groupCount, materialIndex);
groupStart += groupCount;
numberOfVertices += vertexCounter;
}
}
}
function cloneUniforms(src) {
var dst = {};
for (var u in src) {
dst[u] = {};
for (var p in src[u]) {
var property = src[u][p];
if (property && (property.isColor || property.isMatrix3 || property.isMatrix4 || property.isVector2 || property.isVector3 || property.isVector4 || property.isTexture)) {
dst[u][p] = property.clone();
} else if (Array.isArray(property)) {
dst[u][p] = property.slice();
} else {
dst[u][p] = property;
}
}
}
return dst;
}
function mergeUniforms(uniforms) {
var merged = {};
for (var u = 0; u < uniforms.length; u++) {
var tmp2 = cloneUniforms(uniforms[u]);
for (var p in tmp2) {
merged[p] = tmp2[p];
}
}
return merged;
}
var UniformsUtils = { clone: cloneUniforms, merge: mergeUniforms };
var default_vertex = "void main() {\n gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}";
var default_fragment = "void main() {\n gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );\n}";
function ShaderMaterial(parameters) {
Material.call(this);
this.type = "ShaderMaterial";
this.defines = {};
this.uniforms = {};
this.vertexShader = default_vertex;
this.fragmentShader = default_fragment;
this.linewidth = 1;
this.wireframe = false;
this.wireframeLinewidth = 1;
this.fog = false;
this.lights = false;
this.clipping = false;
this.skinning = false;
this.morphTargets = false;
this.morphNormals = false;
this.extensions = {
derivatives: false,
// set to use derivatives
fragDepth: false,
// set to use fragment depth values
drawBuffers: false,
// set to use draw buffers
shaderTextureLOD: false
// set to use shader texture LOD
};
this.defaultAttributeValues = {
"color": [1, 1, 1],
"uv": [0, 0],
"uv2": [0, 0]
};
this.index0AttributeName = void 0;
this.uniformsNeedUpdate = false;
if (parameters !== void 0) {
if (parameters.attributes !== void 0) {
console.error("THREE.ShaderMaterial: attributes should now be defined in THREE.BufferGeometry instead.");
}
this.setValues(parameters);
}
}
ShaderMaterial.prototype = Object.create(Material.prototype);
ShaderMaterial.prototype.constructor = ShaderMaterial;
ShaderMaterial.prototype.isShaderMaterial = true;
ShaderMaterial.prototype.copy = function(source) {
Material.prototype.copy.call(this, source);
this.fragmentShader = source.fragmentShader;
this.vertexShader = source.vertexShader;
this.uniforms = cloneUniforms(source.uniforms);
this.defines = Object.assign({}, source.defines);
this.wireframe = source.wireframe;
this.wireframeLinewidth = source.wireframeLinewidth;
this.lights = source.lights;
this.clipping = source.clipping;
this.skinning = source.skinning;
this.morphTargets = source.morphTargets;
this.morphNormals = source.morphNormals;
this.extensions = source.extensions;
return this;
};
ShaderMaterial.prototype.toJSON = function(meta) {
var data = Material.prototype.toJSON.call(this, meta);
data.uniforms = {};
for (var name in this.uniforms) {
var uniform = this.uniforms[name];
var value = uniform.value;
if (value && value.isTexture) {
data.uniforms[name] = {
type: "t",
value: value.toJSON(meta).uuid
};
} else if (value && value.isColor) {
data.uniforms[name] = {
type: "c",
value: value.getHex()
};
} else if (value && value.isVector2) {
data.uniforms[name] = {
type: "v2",
value: value.toArray()
};
} else if (value && value.isVector3) {
data.uniforms[name] = {
type: "v3",
value: value.toArray()
};
} else if (value && value.isVector4) {
data.uniforms[name] = {
type: "v4",
value: value.toArray()
};
} else if (value && value.isMatrix3) {
data.uniforms[name] = {
type: "m3",
value: value.toArray()
};
} else if (value && value.isMatrix4) {
data.uniforms[name] = {
type: "m4",
value: value.toArray()
};
} else {
data.uniforms[name] = {
value
};
}
}
if (Object.keys(this.defines).length > 0)
data.defines = this.defines;
data.vertexShader = this.vertexShader;
data.fragmentShader = this.fragmentShader;
var extensions = {};
for (var key in this.extensions) {
if (this.extensions[key] === true)
extensions[key] = true;
}
if (Object.keys(extensions).length > 0)
data.extensions = extensions;
return data;
};
function Camera() {
Object3D.call(this);
this.type = "Camera";
this.matrixWorldInverse = new Matrix4();
this.projectionMatrix = new Matrix4();
this.projectionMatrixInverse = new Matrix4();
}
Camera.prototype = Object.assign(Object.create(Object3D.prototype), {
constructor: Camera,
isCamera: true,
copy: function(source, recursive) {
Object3D.prototype.copy.call(this, source, recursive);
this.matrixWorldInverse.copy(source.matrixWorldInverse);
this.projectionMatrix.copy(source.projectionMatrix);
this.projectionMatrixInverse.copy(source.projectionMatrixInverse);
return this;
},
getWorldDirection: function(target) {
if (target === void 0) {
console.warn("THREE.Camera: .getWorldDirection() target is now required");
target = new Vector3();
}
this.updateMatrixWorld(true);
var e = this.matrixWorld.elements;
return target.set(-e[8], -e[9], -e[10]).normalize();
},
updateMatrixWorld: function(force) {
Object3D.prototype.updateMatrixWorld.call(this, force);
this.matrixWorldInverse.getInverse(this.matrixWorld);
},
updateWorldMatrix: function(updateParents, updateChildren) {
Object3D.prototype.updateWorldMatrix.call(this, updateParents, updateChildren);
this.matrixWorldInverse.getInverse(this.matrixWorld);
},
clone: function() {
return new this.constructor().copy(this);
}
});
function PerspectiveCamera(fov2, aspect2, near, far) {
Camera.call(this);
this.type = "PerspectiveCamera";
this.fov = fov2 !== void 0 ? fov2 : 50;
this.zoom = 1;
this.near = near !== void 0 ? near : 0.1;
this.far = far !== void 0 ? far : 2e3;
this.focus = 10;
this.aspect = aspect2 !== void 0 ? aspect2 : 1;
this.view = null;
this.filmGauge = 35;
this.filmOffset = 0;
this.updateProjectionMatrix();
}
PerspectiveCamera.prototype = Object.assign(Object.create(Camera.prototype), {
constructor: PerspectiveCamera,
isPerspectiveCamera: true,
copy: function(source, recursive) {
Camera.prototype.copy.call(this, source, recursive);
this.fov = source.fov;
this.zoom = source.zoom;
this.near = source.near;
this.far = source.far;
this.focus = source.focus;
this.aspect = source.aspect;
this.view = source.view === null ? null : Object.assign({}, source.view);
this.filmGauge = source.filmGauge;
this.filmOffset = source.filmOffset;
return this;
},
/**
* Sets the FOV by focal length in respect to the current .filmGauge.
*
* The default film gauge is 35, so that the focal length can be specified for
* a 35mm (full frame) camera.
*
* Values for focal length and film gauge must have the same unit.
*/
setFocalLength: function(focalLength) {
var vExtentSlope = 0.5 * this.getFilmHeight() / focalLength;
this.fov = MathUtils.RAD2DEG * 2 * Math.atan(vExtentSlope);
this.updateProjectionMatrix();
},
/**
* Calculates the focal length from the current .fov and .filmGauge.
*/
getFocalLength: function() {
var vExtentSlope = Math.tan(MathUtils.DEG2RAD * 0.5 * this.fov);
return 0.5 * this.getFilmHeight() / vExtentSlope;
},
getEffectiveFOV: function() {
return MathUtils.RAD2DEG * 2 * Math.atan(
Math.tan(MathUtils.DEG2RAD * 0.5 * this.fov) / this.zoom
);
},
getFilmWidth: function() {
return this.filmGauge * Math.min(this.aspect, 1);
},
getFilmHeight: function() {
return this.filmGauge / Math.max(this.aspect, 1);
},
/**
* Sets an offset in a larger frustum. This is useful for multi-window or
* multi-monitor/multi-machine setups.
*
* For example, if you have 3x2 monitors and each monitor is 1920x1080 and
* the monitors are in grid like this
*
* +---+---+---+
* | A | B | C |
* +---+---+---+
* | D | E | F |
* +---+---+---+
*
* then for each monitor you would call it like this
*
* var w = 1920;
* var h = 1080;
* var fullWidth = w * 3;
* var fullHeight = h * 2;
*
* --A--
* camera.setViewOffset( fullWidth, fullHeight, w * 0, h * 0, w, h );
* --B--
* camera.setViewOffset( fullWidth, fullHeight, w * 1, h * 0, w, h );
* --C--
* camera.setViewOffset( fullWidth, fullHeight, w * 2, h * 0, w, h );
* --D--
* camera.setViewOffset( fullWidth, fullHeight, w * 0, h * 1, w, h );
* --E--
* camera.setViewOffset( fullWidth, fullHeight, w * 1, h * 1, w, h );
* --F--
* camera.setViewOffset( fullWidth, fullHeight, w * 2, h * 1, w, h );
*
* Note there is no reason monitors have to be the same size or in a grid.
*/
setViewOffset: function(fullWidth, fullHeight, x, y, width, height) {
this.aspect = fullWidth / fullHeight;
if (this.view === null) {
this.view = {
enabled: true,
fullWidth: 1,
fullHeight: 1,
offsetX: 0,
offsetY: 0,
width: 1,
height: 1
};
}
this.view.enabled = true;
this.view.fullWidth = fullWidth;
this.view.fullHeight = fullHeight;
this.view.offsetX = x;
this.view.offsetY = y;
this.view.width = width;
this.view.height = height;
this.updateProjectionMatrix();
},
clearViewOffset: function() {
if (this.view !== null) {
this.view.enabled = false;
}
this.updateProjectionMatrix();
},
updateProjectionMatrix: function() {
var near = this.near, top2 = near * Math.tan(MathUtils.DEG2RAD * 0.5 * this.fov) / this.zoom, height = 2 * top2, width = this.aspect * height, left = -0.5 * width, view = this.view;
if (this.view !== null && this.view.enabled) {
var fullWidth = view.fullWidth, fullHeight = view.fullHeight;
left += view.offsetX * width / fullWidth;
top2 -= view.offsetY * height / fullHeight;
width *= view.width / fullWidth;
height *= view.height / fullHeight;
}
var skew = this.filmOffset;
if (skew !== 0)
left += near * skew / this.getFilmWidth();
this.projectionMatrix.makePerspective(left, left + width, top2, top2 - height, near, this.far);
this.projectionMatrixInverse.getInverse(this.projectionMatrix);
},
toJSON: function(meta) {
var data = Object3D.prototype.toJSON.call(this, meta);
data.object.fov = this.fov;
data.object.zoom = this.zoom;
data.object.near = this.near;
data.object.far = this.far;
data.object.focus = this.focus;
data.object.aspect = this.aspect;
if (this.view !== null)
data.object.view = Object.assign({}, this.view);
data.object.filmGauge = this.filmGauge;
data.object.filmOffset = this.filmOffset;
return data;
}
});
var fov = 90, aspect = 1;
function CubeCamera(near, far, cubeResolution, options) {
Object3D.call(this);
this.type = "CubeCamera";
var cameraPX = new PerspectiveCamera(fov, aspect, near, far);
cameraPX.up.set(0, -1, 0);
cameraPX.lookAt(new Vector3(1, 0, 0));
this.add(cameraPX);
var cameraNX = new PerspectiveCamera(fov, aspect, near, far);
cameraNX.up.set(0, -1, 0);
cameraNX.lookAt(new Vector3(-1, 0, 0));
this.add(cameraNX);
var cameraPY = new PerspectiveCamera(fov, aspect, near, far);
cameraPY.up.set(0, 0, 1);
cameraPY.lookAt(new Vector3(0, 1, 0));
this.add(cameraPY);
var cameraNY = new PerspectiveCamera(fov, aspect, near, far);
cameraNY.up.set(0, 0, -1);
cameraNY.lookAt(new Vector3(0, -1, 0));
this.add(cameraNY);
var cameraPZ = new PerspectiveCamera(fov, aspect, near, far);
cameraPZ.up.set(0, -1, 0);
cameraPZ.lookAt(new Vector3(0, 0, 1));
this.add(cameraPZ);
var cameraNZ = new PerspectiveCamera(fov, aspect, near, far);
cameraNZ.up.set(0, -1, 0);
cameraNZ.lookAt(new Vector3(0, 0, -1));
this.add(cameraNZ);
options = options || { format: RGBFormat, magFilter: LinearFilter, minFilter: LinearFilter };
this.renderTarget = new WebGLCubeRenderTarget(cubeResolution, options);
this.renderTarget.texture.name = "CubeCamera";
this.update = function(renderer, scene) {
if (this.parent === null)
this.updateMatrixWorld();
var currentRenderTarget = renderer.getRenderTarget();
var renderTarget = this.renderTarget;
var generateMipmaps = renderTarget.texture.generateMipmaps;
renderTarget.texture.generateMipmaps = false;
renderer.setRenderTarget(renderTarget, 0);
renderer.render(scene, cameraPX);
renderer.setRenderTarget(renderTarget, 1);
renderer.render(scene, cameraNX);
renderer.setRenderTarget(renderTarget, 2);
renderer.render(scene, cameraPY);
renderer.setRenderTarget(renderTarget, 3);
renderer.render(scene, cameraNY);
renderer.setRenderTarget(renderTarget, 4);
renderer.render(scene, cameraPZ);
renderTarget.texture.generateMipmaps = generateMipmaps;
renderer.setRenderTarget(renderTarget, 5);
renderer.render(scene, cameraNZ);
renderer.setRenderTarget(currentRenderTarget);
};
this.clear = function(renderer, color, depth, stencil) {
var currentRenderTarget = renderer.getRenderTarget();
var renderTarget = this.renderTarget;
for (var i2 = 0; i2 < 6; i2++) {
renderer.setRenderTarget(renderTarget, i2);
renderer.clear(color, depth, stencil);
}
renderer.setRenderTarget(currentRenderTarget);
};
}
CubeCamera.prototype = Object.create(Object3D.prototype);
CubeCamera.prototype.constructor = CubeCamera;
function WebGLCubeRenderTarget(size, options, dummy) {
if (Number.isInteger(options)) {
console.warn("THREE.WebGLCubeRenderTarget: constructor signature is now WebGLCubeRenderTarget( size, options )");
options = dummy;
}
WebGLRenderTarget.call(this, size, size, options);
}
WebGLCubeRenderTarget.prototype = Object.create(WebGLRenderTarget.prototype);
WebGLCubeRenderTarget.prototype.constructor = WebGLCubeRenderTarget;
WebGLCubeRenderTarget.prototype.isWebGLCubeRenderTarget = true;
WebGLCubeRenderTarget.prototype.fromEquirectangularTexture = function(renderer, texture) {
this.texture.type = texture.type;
this.texture.format = texture.format;
this.texture.encoding = texture.encoding;
var scene = new Scene();
var shader = {
uniforms: {
tEquirect: { value: null }
},
vertexShader: [
"varying vec3 vWorldDirection;",
"vec3 transformDirection( in vec3 dir, in mat4 matrix ) {",
" return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );",
"}",
"void main() {",
" vWorldDirection = transformDirection( position, modelMatrix );",
" #include ",
" #include ",
"}"
].join("\n"),
fragmentShader: [
"uniform sampler2D tEquirect;",
"varying vec3 vWorldDirection;",
"#define RECIPROCAL_PI 0.31830988618",
"#define RECIPROCAL_PI2 0.15915494",
"void main() {",
" vec3 direction = normalize( vWorldDirection );",
" vec2 sampleUV;",
" sampleUV.y = asin( clamp( direction.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;",
" sampleUV.x = atan( direction.z, direction.x ) * RECIPROCAL_PI2 + 0.5;",
" gl_FragColor = texture2D( tEquirect, sampleUV );",
"}"
].join("\n")
};
var material = new ShaderMaterial({
type: "CubemapFromEquirect",
uniforms: cloneUniforms(shader.uniforms),
vertexShader: shader.vertexShader,
fragmentShader: shader.fragmentShader,
side: BackSide,
blending: NoBlending
});
material.uniforms.tEquirect.value = texture;
var mesh = new Mesh(new BoxBufferGeometry(5, 5, 5), material);
scene.add(mesh);
var camera = new CubeCamera(1, 10, 1);
camera.renderTarget = this;
camera.renderTarget.texture.name = "CubeCameraTexture";
camera.update(renderer, scene);
mesh.geometry.dispose();
mesh.material.dispose();
return this;
};
function DataTexture(data, width, height, format, type, mapping, wrapS, wrapT, magFilter, minFilter, anisotropy, encoding) {
Texture.call(this, null, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy, encoding);
this.image = { data: data || null, width: width || 1, height: height || 1 };
this.magFilter = magFilter !== void 0 ? magFilter : NearestFilter;
this.minFilter = minFilter !== void 0 ? minFilter : NearestFilter;
this.generateMipmaps = false;
this.flipY = false;
this.unpackAlignment = 1;
this.needsUpdate = true;
}
DataTexture.prototype = Object.create(Texture.prototype);
DataTexture.prototype.constructor = DataTexture;
DataTexture.prototype.isDataTexture = true;
var _sphere$1 = new Sphere();
var _vector$5 = new Vector3();
function Frustum(p0, p1, p2, p3, p4, p5) {
this.planes = [
p0 !== void 0 ? p0 : new Plane(),
p1 !== void 0 ? p1 : new Plane(),
p2 !== void 0 ? p2 : new Plane(),
p3 !== void 0 ? p3 : new Plane(),
p4 !== void 0 ? p4 : new Plane(),
p5 !== void 0 ? p5 : new Plane()
];
}
Object.assign(Frustum.prototype, {
set: function(p0, p1, p2, p3, p4, p5) {
var planes = this.planes;
planes[0].copy(p0);
planes[1].copy(p1);
planes[2].copy(p2);
planes[3].copy(p3);
planes[4].copy(p4);
planes[5].copy(p5);
return this;
},
clone: function() {
return new this.constructor().copy(this);
},
copy: function(frustum) {
var planes = this.planes;
for (var i2 = 0; i2 < 6; i2++) {
planes[i2].copy(frustum.planes[i2]);
}
return this;
},
setFromProjectionMatrix: function(m) {
var planes = this.planes;
var me = m.elements;
var me0 = me[0], me1 = me[1], me2 = me[2], me3 = me[3];
var me4 = me[4], me5 = me[5], me6 = me[6], me7 = me[7];
var me8 = me[8], me9 = me[9], me10 = me[10], me11 = me[11];
var me12 = me[12], me13 = me[13], me14 = me[14], me15 = me[15];
planes[0].setComponents(me3 - me0, me7 - me4, me11 - me8, me15 - me12).normalize();
planes[1].setComponents(me3 + me0, me7 + me4, me11 + me8, me15 + me12).normalize();
planes[2].setComponents(me3 + me1, me7 + me5, me11 + me9, me15 + me13).normalize();
planes[3].setComponents(me3 - me1, me7 - me5, me11 - me9, me15 - me13).normalize();
planes[4].setComponents(me3 - me2, me7 - me6, me11 - me10, me15 - me14).normalize();
planes[5].setComponents(me3 + me2, me7 + me6, me11 + me10, me15 + me14).normalize();
return this;
},
intersectsObject: function(object) {
var geometry = object.geometry;
if (geometry.boundingSphere === null)
geometry.computeBoundingSphere();
_sphere$1.copy(geometry.boundingSphere).applyMatrix4(object.matrixWorld);
return this.intersectsSphere(_sphere$1);
},
intersectsSprite: function(sprite) {
_sphere$1.center.set(0, 0, 0);
_sphere$1.radius = 0.7071067811865476;
_sphere$1.applyMatrix4(sprite.matrixWorld);
return this.intersectsSphere(_sphere$1);
},
intersectsSphere: function(sphere) {
var planes = this.planes;
var center = sphere.center;
var negRadius = -sphere.radius;
for (var i2 = 0; i2 < 6; i2++) {
var distance = planes[i2].distanceToPoint(center);
if (distance < negRadius) {
return false;
}
}
return true;
},
intersectsBox: function(box) {
var planes = this.planes;
for (var i2 = 0; i2 < 6; i2++) {
var plane = planes[i2];
_vector$5.x = plane.normal.x > 0 ? box.max.x : box.min.x;
_vector$5.y = plane.normal.y > 0 ? box.max.y : box.min.y;
_vector$5.z = plane.normal.z > 0 ? box.max.z : box.min.z;
if (plane.distanceToPoint(_vector$5) < 0) {
return false;
}
}
return true;
},
containsPoint: function(point) {
var planes = this.planes;
for (var i2 = 0; i2 < 6; i2++) {
if (planes[i2].distanceToPoint(point) < 0) {
return false;
}
}
return true;
}
});
var UniformsLib = {
common: {
diffuse: { value: new Color(15658734) },
opacity: { value: 1 },
map: { value: null },
uvTransform: { value: new Matrix3() },
uv2Transform: { value: new Matrix3() },
alphaMap: { value: null }
},
specularmap: {
specularMap: { value: null }
},
envmap: {
envMap: { value: null },
flipEnvMap: { value: -1 },
reflectivity: { value: 1 },
refractionRatio: { value: 0.98 },
maxMipLevel: { value: 0 }
},
aomap: {
aoMap: { value: null },
aoMapIntensity: { value: 1 }
},
lightmap: {
lightMap: { value: null },
lightMapIntensity: { value: 1 }
},
emissivemap: {
emissiveMap: { value: null }
},
bumpmap: {
bumpMap: { value: null },
bumpScale: { value: 1 }
},
normalmap: {
normalMap: { value: null },
normalScale: { value: new Vector2(1, 1) }
},
displacementmap: {
displacementMap: { value: null },
displacementScale: { value: 1 },
displacementBias: { value: 0 }
},
roughnessmap: {
roughnessMap: { value: null }
},
metalnessmap: {
metalnessMap: { value: null }
},
gradientmap: {
gradientMap: { value: null }
},
fog: {
fogDensity: { value: 25e-5 },
fogNear: { value: 1 },
fogFar: { value: 2e3 },
fogColor: { value: new Color(16777215) }
},
lights: {
ambientLightColor: { value: [] },
lightProbe: { value: [] },
directionalLights: { value: [], properties: {
direction: {},
color: {},
shadow: {},
shadowBias: {},
shadowRadius: {},
shadowMapSize: {}
} },
directionalShadowMap: { value: [] },
directionalShadowMatrix: { value: [] },
spotLights: { value: [], properties: {
color: {},
position: {},
direction: {},
distance: {},
coneCos: {},
penumbraCos: {},
decay: {},
shadow: {},
shadowBias: {},
shadowRadius: {},
shadowMapSize: {}
} },
spotShadowMap: { value: [] },
spotShadowMatrix: { value: [] },
pointLights: { value: [], properties: {
color: {},
position: {},
decay: {},
distance: {},
shadow: {},
shadowBias: {},
shadowRadius: {},
shadowMapSize: {},
shadowCameraNear: {},
shadowCameraFar: {}
} },
pointShadowMap: { value: [] },
pointShadowMatrix: { value: [] },
hemisphereLights: { value: [], properties: {
direction: {},
skyColor: {},
groundColor: {}
} },
// TODO (abelnation): RectAreaLight BRDF data needs to be moved from example to main src
rectAreaLights: { value: [], properties: {
color: {},
position: {},
width: {},
height: {}
} }
},
points: {
diffuse: { value: new Color(15658734) },
opacity: { value: 1 },
size: { value: 1 },
scale: { value: 1 },
map: { value: null },
alphaMap: { value: null },
uvTransform: { value: new Matrix3() }
},
sprite: {
diffuse: { value: new Color(15658734) },
opacity: { value: 1 },
center: { value: new Vector2(0.5, 0.5) },
rotation: { value: 0 },
map: { value: null },
alphaMap: { value: null },
uvTransform: { value: new Matrix3() }
}
};
function WebGLAnimation() {
var context = null;
var isAnimating = false;
var animationLoop = null;
function onAnimationFrame(time, frame) {
if (isAnimating === false)
return;
animationLoop(time, frame);
context.requestAnimationFrame(onAnimationFrame);
}
return {
start: function() {
if (isAnimating === true)
return;
if (animationLoop === null)
return;
context.requestAnimationFrame(onAnimationFrame);
isAnimating = true;
},
stop: function() {
isAnimating = false;
},
setAnimationLoop: function(callback) {
animationLoop = callback;
},
setContext: function(value) {
context = value;
}
};
}
function WebGLAttributes(gl, capabilities) {
var isWebGL2 = capabilities.isWebGL2;
var buffers = /* @__PURE__ */ new WeakMap();
function createBuffer(attribute, bufferType) {
var array = attribute.array;
var usage = attribute.usage;
var buffer = gl.createBuffer();
gl.bindBuffer(bufferType, buffer);
gl.bufferData(bufferType, array, usage);
attribute.onUploadCallback();
var type = 5126;
if (array instanceof Float32Array) {
type = 5126;
} else if (array instanceof Float64Array) {
console.warn("THREE.WebGLAttributes: Unsupported data buffer format: Float64Array.");
} else if (array instanceof Uint16Array) {
type = 5123;
} else if (array instanceof Int16Array) {
type = 5122;
} else if (array instanceof Uint32Array) {
type = 5125;
} else if (array instanceof Int32Array) {
type = 5124;
} else if (array instanceof Int8Array) {
type = 5120;
} else if (array instanceof Uint8Array) {
type = 5121;
}
return {
buffer,
type,
bytesPerElement: array.BYTES_PER_ELEMENT,
version: attribute.version
};
}
function updateBuffer(buffer, attribute, bufferType) {
var array = attribute.array;
var updateRange = attribute.updateRange;
gl.bindBuffer(bufferType, buffer);
if (updateRange.count === -1) {
gl.bufferSubData(bufferType, 0, array);
} else {
if (isWebGL2) {
gl.bufferSubData(
bufferType,
updateRange.offset * array.BYTES_PER_ELEMENT,
array,
updateRange.offset,
updateRange.count
);
} else {
gl.bufferSubData(
bufferType,
updateRange.offset * array.BYTES_PER_ELEMENT,
array.subarray(updateRange.offset, updateRange.offset + updateRange.count)
);
}
updateRange.count = -1;
}
}
function get(attribute) {
if (attribute.isInterleavedBufferAttribute)
attribute = attribute.data;
return buffers.get(attribute);
}
function remove(attribute) {
if (attribute.isInterleavedBufferAttribute)
attribute = attribute.data;
var data = buffers.get(attribute);
if (data) {
gl.deleteBuffer(data.buffer);
buffers.delete(attribute);
}
}
function update(attribute, bufferType) {
if (attribute.isInterleavedBufferAttribute)
attribute = attribute.data;
var data = buffers.get(attribute);
if (data === void 0) {
buffers.set(attribute, createBuffer(attribute, bufferType));
} else if (data.version < attribute.version) {
updateBuffer(data.buffer, attribute, bufferType);
data.version = attribute.version;
}
}
return {
get,
remove,
update
};
}
function PlaneGeometry(width, height, widthSegments, heightSegments) {
Geometry.call(this);
this.type = "PlaneGeometry";
this.parameters = {
width,
height,
widthSegments,
heightSegments
};
this.fromBufferGeometry(new PlaneBufferGeometry(width, height, widthSegments, heightSegments));
this.mergeVertices();
}
PlaneGeometry.prototype = Object.create(Geometry.prototype);
PlaneGeometry.prototype.constructor = PlaneGeometry;
function PlaneBufferGeometry(width, height, widthSegments, heightSegments) {
BufferGeometry.call(this);
this.type = "PlaneBufferGeometry";
this.parameters = {
width,
height,
widthSegments,
heightSegments
};
width = width || 1;
height = height || 1;
var width_half = width / 2;
var height_half = height / 2;
var gridX = Math.floor(widthSegments) || 1;
var gridY = Math.floor(heightSegments) || 1;
var gridX1 = gridX + 1;
var gridY1 = gridY + 1;
var segment_width = width / gridX;
var segment_height = height / gridY;
var ix, iy;
var indices = [];
var vertices = [];
var normals = [];
var uvs = [];
for (iy = 0; iy < gridY1; iy++) {
var y = iy * segment_height - height_half;
for (ix = 0; ix < gridX1; ix++) {
var x = ix * segment_width - width_half;
vertices.push(x, -y, 0);
normals.push(0, 0, 1);
uvs.push(ix / gridX);
uvs.push(1 - iy / gridY);
}
}
for (iy = 0; iy < gridY; iy++) {
for (ix = 0; ix < gridX; ix++) {
var a = ix + gridX1 * iy;
var b = ix + gridX1 * (iy + 1);
var c = ix + 1 + gridX1 * (iy + 1);
var d = ix + 1 + gridX1 * iy;
indices.push(a, b, d);
indices.push(b, c, d);
}
}
this.setIndex(indices);
this.setAttribute("position", new Float32BufferAttribute(vertices, 3));
this.setAttribute("normal", new Float32BufferAttribute(normals, 3));
this.setAttribute("uv", new Float32BufferAttribute(uvs, 2));
}
PlaneBufferGeometry.prototype = Object.create(BufferGeometry.prototype);
PlaneBufferGeometry.prototype.constructor = PlaneBufferGeometry;
var alphamap_fragment = "#ifdef USE_ALPHAMAP\n diffuseColor.a *= texture2D( alphaMap, vUv ).g;\n#endif";
var alphamap_pars_fragment = "#ifdef USE_ALPHAMAP\n uniform sampler2D alphaMap;\n#endif";
var alphatest_fragment = "#ifdef ALPHATEST\n if ( diffuseColor.a < ALPHATEST ) discard;\n#endif";
var aomap_fragment = "#ifdef USE_AOMAP\n float ambientOcclusion = ( texture2D( aoMap, vUv2 ).r - 1.0 ) * aoMapIntensity + 1.0;\n reflectedLight.indirectDiffuse *= ambientOcclusion;\n #if defined( USE_ENVMAP ) && defined( STANDARD )\n float dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n reflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.specularRoughness );\n #endif\n#endif";
var aomap_pars_fragment = "#ifdef USE_AOMAP\n uniform sampler2D aoMap;\n uniform float aoMapIntensity;\n#endif";
var begin_vertex = "vec3 transformed = vec3( position );";
var beginnormal_vertex = "vec3 objectNormal = vec3( normal );\n#ifdef USE_TANGENT\n vec3 objectTangent = vec3( tangent.xyz );\n#endif";
var bsdfs = "vec2 integrateSpecularBRDF( const in float dotNV, const in float roughness ) {\n const vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );\n const vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );\n vec4 r = roughness * c0 + c1;\n float a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;\n return vec2( -1.04, 1.04 ) * a004 + r.zw;\n}\nfloat punctualLightIntensityToIrradianceFactor( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {\n#if defined ( PHYSICALLY_CORRECT_LIGHTS )\n float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );\n if( cutoffDistance > 0.0 ) {\n distanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );\n }\n return distanceFalloff;\n#else\n if( cutoffDistance > 0.0 && decayExponent > 0.0 ) {\n return pow( saturate( -lightDistance / cutoffDistance + 1.0 ), decayExponent );\n }\n return 1.0;\n#endif\n}\nvec3 BRDF_Diffuse_Lambert( const in vec3 diffuseColor ) {\n return RECIPROCAL_PI * diffuseColor;\n}\nvec3 F_Schlick( const in vec3 specularColor, const in float dotLH ) {\n float fresnel = exp2( ( -5.55473 * dotLH - 6.98316 ) * dotLH );\n return ( 1.0 - specularColor ) * fresnel + specularColor;\n}\nvec3 F_Schlick_RoughnessDependent( const in vec3 F0, const in float dotNV, const in float roughness ) {\n float fresnel = exp2( ( -5.55473 * dotNV - 6.98316 ) * dotNV );\n vec3 Fr = max( vec3( 1.0 - roughness ), F0 ) - F0;\n return Fr * fresnel + F0;\n}\nfloat G_GGX_Smith( const in float alpha, const in float dotNL, const in float dotNV ) {\n float a2 = pow2( alpha );\n float gl = dotNL + sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n float gv = dotNV + sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n return 1.0 / ( gl * gv );\n}\nfloat G_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {\n float a2 = pow2( alpha );\n float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n return 0.5 / max( gv + gl, EPSILON );\n}\nfloat D_GGX( const in float alpha, const in float dotNH ) {\n float a2 = pow2( alpha );\n float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;\n return RECIPROCAL_PI * a2 / pow2( denom );\n}\nvec3 BRDF_Specular_GGX( const in IncidentLight incidentLight, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float roughness ) {\n float alpha = pow2( roughness );\n vec3 halfDir = normalize( incidentLight.direction + viewDir );\n float dotNL = saturate( dot( normal, incidentLight.direction ) );\n float dotNV = saturate( dot( normal, viewDir ) );\n float dotNH = saturate( dot( normal, halfDir ) );\n float dotLH = saturate( dot( incidentLight.direction, halfDir ) );\n vec3 F = F_Schlick( specularColor, dotLH );\n float G = G_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n float D = D_GGX( alpha, dotNH );\n return F * ( G * D );\n}\nvec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {\n const float LUT_SIZE = 64.0;\n const float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;\n const float LUT_BIAS = 0.5 / LUT_SIZE;\n float dotNV = saturate( dot( N, V ) );\n vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );\n uv = uv * LUT_SCALE + LUT_BIAS;\n return uv;\n}\nfloat LTC_ClippedSphereFormFactor( const in vec3 f ) {\n float l = length( f );\n return max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );\n}\nvec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {\n float x = dot( v1, v2 );\n float y = abs( x );\n float a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;\n float b = 3.4175940 + ( 4.1616724 + y ) * y;\n float v = a / b;\n float theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;\n return cross( v1, v2 ) * theta_sintheta;\n}\nvec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {\n vec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];\n vec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];\n vec3 lightNormal = cross( v1, v2 );\n if( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );\n vec3 T1, T2;\n T1 = normalize( V - N * dot( V, N ) );\n T2 = - cross( N, T1 );\n mat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );\n vec3 coords[ 4 ];\n coords[ 0 ] = mat * ( rectCoords[ 0 ] - P );\n coords[ 1 ] = mat * ( rectCoords[ 1 ] - P );\n coords[ 2 ] = mat * ( rectCoords[ 2 ] - P );\n coords[ 3 ] = mat * ( rectCoords[ 3 ] - P );\n coords[ 0 ] = normalize( coords[ 0 ] );\n coords[ 1 ] = normalize( coords[ 1 ] );\n coords[ 2 ] = normalize( coords[ 2 ] );\n coords[ 3 ] = normalize( coords[ 3 ] );\n vec3 vectorFormFactor = vec3( 0.0 );\n vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );\n vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );\n vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );\n vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );\n float result = LTC_ClippedSphereFormFactor( vectorFormFactor );\n return vec3( result );\n}\nvec3 BRDF_Specular_GGX_Environment( const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float roughness ) {\n float dotNV = saturate( dot( normal, viewDir ) );\n vec2 brdf = integrateSpecularBRDF( dotNV, roughness );\n return specularColor * brdf.x + brdf.y;\n}\nvoid BRDF_Specular_Multiscattering_Environment( const in GeometricContext geometry, const in vec3 specularColor, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {\n float dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n vec3 F = F_Schlick_RoughnessDependent( specularColor, dotNV, roughness );\n vec2 brdf = integrateSpecularBRDF( dotNV, roughness );\n vec3 FssEss = F * brdf.x + brdf.y;\n float Ess = brdf.x + brdf.y;\n float Ems = 1.0 - Ess;\n vec3 Favg = specularColor + ( 1.0 - specularColor ) * 0.047619; vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );\n singleScatter += FssEss;\n multiScatter += Fms * Ems;\n}\nfloat G_BlinnPhong_Implicit( ) {\n return 0.25;\n}\nfloat D_BlinnPhong( const in float shininess, const in float dotNH ) {\n return RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );\n}\nvec3 BRDF_Specular_BlinnPhong( const in IncidentLight incidentLight, const in GeometricContext geometry, const in vec3 specularColor, const in float shininess ) {\n vec3 halfDir = normalize( incidentLight.direction + geometry.viewDir );\n float dotNH = saturate( dot( geometry.normal, halfDir ) );\n float dotLH = saturate( dot( incidentLight.direction, halfDir ) );\n vec3 F = F_Schlick( specularColor, dotLH );\n float G = G_BlinnPhong_Implicit( );\n float D = D_BlinnPhong( shininess, dotNH );\n return F * ( G * D );\n}\nfloat GGXRoughnessToBlinnExponent( const in float ggxRoughness ) {\n return ( 2.0 / pow2( ggxRoughness + 0.0001 ) - 2.0 );\n}\nfloat BlinnExponentToGGXRoughness( const in float blinnExponent ) {\n return sqrt( 2.0 / ( blinnExponent + 2.0 ) );\n}\n#if defined( USE_SHEEN )\nfloat D_Charlie(float roughness, float NoH) {\n float invAlpha = 1.0 / roughness;\n float cos2h = NoH * NoH;\n float sin2h = max(1.0 - cos2h, 0.0078125); return (2.0 + invAlpha) * pow(sin2h, invAlpha * 0.5) / (2.0 * PI);\n}\nfloat V_Neubelt(float NoV, float NoL) {\n return saturate(1.0 / (4.0 * (NoL + NoV - NoL * NoV)));\n}\nvec3 BRDF_Specular_Sheen( const in float roughness, const in vec3 L, const in GeometricContext geometry, vec3 specularColor ) {\n vec3 N = geometry.normal;\n vec3 V = geometry.viewDir;\n vec3 H = normalize( V + L );\n float dotNH = saturate( dot( N, H ) );\n return specularColor * D_Charlie( roughness, dotNH ) * V_Neubelt( dot(N, V), dot(N, L) );\n}\n#endif";
var bumpmap_pars_fragment = "#ifdef USE_BUMPMAP\n uniform sampler2D bumpMap;\n uniform float bumpScale;\n vec2 dHdxy_fwd() {\n vec2 dSTdx = dFdx( vUv );\n vec2 dSTdy = dFdy( vUv );\n float Hll = bumpScale * texture2D( bumpMap, vUv ).x;\n float dBx = bumpScale * texture2D( bumpMap, vUv + dSTdx ).x - Hll;\n float dBy = bumpScale * texture2D( bumpMap, vUv + dSTdy ).x - Hll;\n return vec2( dBx, dBy );\n }\n vec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy ) {\n vec3 vSigmaX = vec3( dFdx( surf_pos.x ), dFdx( surf_pos.y ), dFdx( surf_pos.z ) );\n vec3 vSigmaY = vec3( dFdy( surf_pos.x ), dFdy( surf_pos.y ), dFdy( surf_pos.z ) );\n vec3 vN = surf_norm;\n vec3 R1 = cross( vSigmaY, vN );\n vec3 R2 = cross( vN, vSigmaX );\n float fDet = dot( vSigmaX, R1 );\n fDet *= ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );\n return normalize( abs( fDet ) * surf_norm - vGrad );\n }\n#endif";
var clipping_planes_fragment = "#if NUM_CLIPPING_PLANES > 0\n vec4 plane;\n #pragma unroll_loop\n for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {\n plane = clippingPlanes[ i ];\n if ( dot( vViewPosition, plane.xyz ) > plane.w ) discard;\n }\n #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES\n bool clipped = true;\n #pragma unroll_loop\n for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {\n plane = clippingPlanes[ i ];\n clipped = ( dot( vViewPosition, plane.xyz ) > plane.w ) && clipped;\n }\n if ( clipped ) discard;\n #endif\n#endif";
var clipping_planes_pars_fragment = "#if NUM_CLIPPING_PLANES > 0\n #if ! defined( STANDARD ) && ! defined( PHONG ) && ! defined( MATCAP )\n varying vec3 vViewPosition;\n #endif\n uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];\n#endif";
var clipping_planes_pars_vertex = "#if NUM_CLIPPING_PLANES > 0 && ! defined( STANDARD ) && ! defined( PHONG ) && ! defined( MATCAP )\n varying vec3 vViewPosition;\n#endif";
var clipping_planes_vertex = "#if NUM_CLIPPING_PLANES > 0 && ! defined( STANDARD ) && ! defined( PHONG ) && ! defined( MATCAP )\n vViewPosition = - mvPosition.xyz;\n#endif";
var color_fragment = "#ifdef USE_COLOR\n diffuseColor.rgb *= vColor;\n#endif";
var color_pars_fragment = "#ifdef USE_COLOR\n varying vec3 vColor;\n#endif";
var color_pars_vertex = "#ifdef USE_COLOR\n varying vec3 vColor;\n#endif";
var color_vertex = "#ifdef USE_COLOR\n vColor.xyz = color.xyz;\n#endif";
var common = "#define PI 3.14159265359\n#define PI2 6.28318530718\n#define PI_HALF 1.5707963267949\n#define RECIPROCAL_PI 0.31830988618\n#define RECIPROCAL_PI2 0.15915494\n#define LOG2 1.442695\n#define EPSILON 1e-6\n#ifndef saturate\n#define saturate(a) clamp( a, 0.0, 1.0 )\n#endif\n#define whiteComplement(a) ( 1.0 - saturate( a ) )\nfloat pow2( const in float x ) { return x*x; }\nfloat pow3( const in float x ) { return x*x*x; }\nfloat pow4( const in float x ) { float x2 = x*x; return x2*x2; }\nfloat average( const in vec3 color ) { return dot( color, vec3( 0.3333 ) ); }\nhighp float rand( const in vec2 uv ) {\n const highp float a = 12.9898, b = 78.233, c = 43758.5453;\n highp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );\n return fract(sin(sn) * c);\n}\n#ifdef HIGH_PRECISION\n float precisionSafeLength( vec3 v ) { return length( v ); }\n#else\n float max3( vec3 v ) { return max( max( v.x, v.y ), v.z ); }\n float precisionSafeLength( vec3 v ) {\n float maxComponent = max3( abs( v ) );\n return length( v / maxComponent ) * maxComponent;\n }\n#endif\nstruct IncidentLight {\n vec3 color;\n vec3 direction;\n bool visible;\n};\nstruct ReflectedLight {\n vec3 directDiffuse;\n vec3 directSpecular;\n vec3 indirectDiffuse;\n vec3 indirectSpecular;\n};\nstruct GeometricContext {\n vec3 position;\n vec3 normal;\n vec3 viewDir;\n#ifdef CLEARCOAT\n vec3 clearcoatNormal;\n#endif\n};\nvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n}\nvec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {\n return normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );\n}\nvec3 projectOnPlane(in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {\n float distance = dot( planeNormal, point - pointOnPlane );\n return - distance * planeNormal + point;\n}\nfloat sideOfPlane( in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {\n return sign( dot( point - pointOnPlane, planeNormal ) );\n}\nvec3 linePlaneIntersect( in vec3 pointOnLine, in vec3 lineDirection, in vec3 pointOnPlane, in vec3 planeNormal ) {\n return lineDirection * ( dot( planeNormal, pointOnPlane - pointOnLine ) / dot( planeNormal, lineDirection ) ) + pointOnLine;\n}\nmat3 transposeMat3( const in mat3 m ) {\n mat3 tmp;\n tmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );\n tmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );\n tmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );\n return tmp;\n}\nfloat linearToRelativeLuminance( const in vec3 color ) {\n vec3 weights = vec3( 0.2126, 0.7152, 0.0722 );\n return dot( weights, color.rgb );\n}\nbool isPerspectiveMatrix( mat4 m ) {\n return m[ 2 ][ 3 ] == - 1.0;\n}";
var cube_uv_reflection_fragment = "#ifdef ENVMAP_TYPE_CUBE_UV\n#define cubeUV_maxMipLevel 8.0\n#define cubeUV_minMipLevel 4.0\n#define cubeUV_maxTileSize 256.0\n#define cubeUV_minTileSize 16.0\nfloat getFace(vec3 direction) {\n vec3 absDirection = abs(direction);\n float face = -1.0;\n if (absDirection.x > absDirection.z) {\n if (absDirection.x > absDirection.y)\n face = direction.x > 0.0 ? 0.0 : 3.0;\n else\n face = direction.y > 0.0 ? 1.0 : 4.0;\n } else {\n if (absDirection.z > absDirection.y)\n face = direction.z > 0.0 ? 2.0 : 5.0;\n else\n face = direction.y > 0.0 ? 1.0 : 4.0;\n }\n return face;\n}\nvec2 getUV(vec3 direction, float face) {\n vec2 uv;\n if (face == 0.0) {\n uv = vec2(-direction.z, direction.y) / abs(direction.x);\n } else if (face == 1.0) {\n uv = vec2(direction.x, -direction.z) / abs(direction.y);\n } else if (face == 2.0) {\n uv = direction.xy / abs(direction.z);\n } else if (face == 3.0) {\n uv = vec2(direction.z, direction.y) / abs(direction.x);\n } else if (face == 4.0) {\n uv = direction.xz / abs(direction.y);\n } else {\n uv = vec2(-direction.x, direction.y) / abs(direction.z);\n }\n return 0.5 * (uv + 1.0);\n}\nvec3 bilinearCubeUV(sampler2D envMap, vec3 direction, float mipInt) {\n float face = getFace(direction);\n float filterInt = max(cubeUV_minMipLevel - mipInt, 0.0);\n mipInt = max(mipInt, cubeUV_minMipLevel);\n float faceSize = exp2(mipInt);\n float texelSize = 1.0 / (3.0 * cubeUV_maxTileSize);\n vec2 uv = getUV(direction, face) * (faceSize - 1.0);\n vec2 f = fract(uv);\n uv += 0.5 - f;\n if (face > 2.0) {\n uv.y += faceSize;\n face -= 3.0;\n }\n uv.x += face * faceSize;\n if(mipInt < cubeUV_maxMipLevel){\n uv.y += 2.0 * cubeUV_maxTileSize;\n }\n uv.y += filterInt * 2.0 * cubeUV_minTileSize;\n uv.x += 3.0 * max(0.0, cubeUV_maxTileSize - 2.0 * faceSize);\n uv *= texelSize;\n vec3 tl = envMapTexelToLinear(texture2D(envMap, uv)).rgb;\n uv.x += texelSize;\n vec3 tr = envMapTexelToLinear(texture2D(envMap, uv)).rgb;\n uv.y += texelSize;\n vec3 br = envMapTexelToLinear(texture2D(envMap, uv)).rgb;\n uv.x -= texelSize;\n vec3 bl = envMapTexelToLinear(texture2D(envMap, uv)).rgb;\n vec3 tm = mix(tl, tr, f.x);\n vec3 bm = mix(bl, br, f.x);\n return mix(tm, bm, f.y);\n}\n#define r0 1.0\n#define v0 0.339\n#define m0 -2.0\n#define r1 0.8\n#define v1 0.276\n#define m1 -1.0\n#define r4 0.4\n#define v4 0.046\n#define m4 2.0\n#define r5 0.305\n#define v5 0.016\n#define m5 3.0\n#define r6 0.21\n#define v6 0.0038\n#define m6 4.0\nfloat roughnessToMip(float roughness) {\n float mip = 0.0;\n if (roughness >= r1) {\n mip = (r0 - roughness) * (m1 - m0) / (r0 - r1) + m0;\n } else if (roughness >= r4) {\n mip = (r1 - roughness) * (m4 - m1) / (r1 - r4) + m1;\n } else if (roughness >= r5) {\n mip = (r4 - roughness) * (m5 - m4) / (r4 - r5) + m4;\n } else if (roughness >= r6) {\n mip = (r5 - roughness) * (m6 - m5) / (r5 - r6) + m5;\n } else {\n mip = -2.0 * log2(1.16 * roughness); }\n return mip;\n}\nvec4 textureCubeUV(sampler2D envMap, vec3 sampleDir, float roughness) {\n float mip = clamp(roughnessToMip(roughness), m0, cubeUV_maxMipLevel);\n float mipF = fract(mip);\n float mipInt = floor(mip);\n vec3 color0 = bilinearCubeUV(envMap, sampleDir, mipInt);\n if (mipF == 0.0) {\n return vec4(color0, 1.0);\n } else {\n vec3 color1 = bilinearCubeUV(envMap, sampleDir, mipInt + 1.0);\n return vec4(mix(color0, color1, mipF), 1.0);\n }\n}\n#endif";
var defaultnormal_vertex = "vec3 transformedNormal = objectNormal;\n#ifdef USE_INSTANCING\n transformedNormal = mat3( instanceMatrix ) * transformedNormal;\n#endif\ntransformedNormal = normalMatrix * transformedNormal;\n#ifdef FLIP_SIDED\n transformedNormal = - transformedNormal;\n#endif\n#ifdef USE_TANGENT\n vec3 transformedTangent = ( modelViewMatrix * vec4( objectTangent, 0.0 ) ).xyz;\n #ifdef FLIP_SIDED\n transformedTangent = - transformedTangent;\n #endif\n#endif";
var displacementmap_pars_vertex = "#ifdef USE_DISPLACEMENTMAP\n uniform sampler2D displacementMap;\n uniform float displacementScale;\n uniform float displacementBias;\n#endif";
var displacementmap_vertex = "#ifdef USE_DISPLACEMENTMAP\n transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vUv ).x * displacementScale + displacementBias );\n#endif";
var emissivemap_fragment = "#ifdef USE_EMISSIVEMAP\n vec4 emissiveColor = texture2D( emissiveMap, vUv );\n emissiveColor.rgb = emissiveMapTexelToLinear( emissiveColor ).rgb;\n totalEmissiveRadiance *= emissiveColor.rgb;\n#endif";
var emissivemap_pars_fragment = "#ifdef USE_EMISSIVEMAP\n uniform sampler2D emissiveMap;\n#endif";
var encodings_fragment = "gl_FragColor = linearToOutputTexel( gl_FragColor );";
var encodings_pars_fragment = "\nvec4 LinearToLinear( in vec4 value ) {\n return value;\n}\nvec4 GammaToLinear( in vec4 value, in float gammaFactor ) {\n return vec4( pow( value.rgb, vec3( gammaFactor ) ), value.a );\n}\nvec4 LinearToGamma( in vec4 value, in float gammaFactor ) {\n return vec4( pow( value.rgb, vec3( 1.0 / gammaFactor ) ), value.a );\n}\nvec4 sRGBToLinear( in vec4 value ) {\n return vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.a );\n}\nvec4 LinearTosRGB( in vec4 value ) {\n return vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a );\n}\nvec4 RGBEToLinear( in vec4 value ) {\n return vec4( value.rgb * exp2( value.a * 255.0 - 128.0 ), 1.0 );\n}\nvec4 LinearToRGBE( in vec4 value ) {\n float maxComponent = max( max( value.r, value.g ), value.b );\n float fExp = clamp( ceil( log2( maxComponent ) ), -128.0, 127.0 );\n return vec4( value.rgb / exp2( fExp ), ( fExp + 128.0 ) / 255.0 );\n}\nvec4 RGBMToLinear( in vec4 value, in float maxRange ) {\n return vec4( value.rgb * value.a * maxRange, 1.0 );\n}\nvec4 LinearToRGBM( in vec4 value, in float maxRange ) {\n float maxRGB = max( value.r, max( value.g, value.b ) );\n float M = clamp( maxRGB / maxRange, 0.0, 1.0 );\n M = ceil( M * 255.0 ) / 255.0;\n return vec4( value.rgb / ( M * maxRange ), M );\n}\nvec4 RGBDToLinear( in vec4 value, in float maxRange ) {\n return vec4( value.rgb * ( ( maxRange / 255.0 ) / value.a ), 1.0 );\n}\nvec4 LinearToRGBD( in vec4 value, in float maxRange ) {\n float maxRGB = max( value.r, max( value.g, value.b ) );\n float D = max( maxRange / maxRGB, 1.0 );\n D = clamp( floor( D ) / 255.0, 0.0, 1.0 );\n return vec4( value.rgb * ( D * ( 255.0 / maxRange ) ), D );\n}\nconst mat3 cLogLuvM = mat3( 0.2209, 0.3390, 0.4184, 0.1138, 0.6780, 0.7319, 0.0102, 0.1130, 0.2969 );\nvec4 LinearToLogLuv( in vec4 value ) {\n vec3 Xp_Y_XYZp = cLogLuvM * value.rgb;\n Xp_Y_XYZp = max( Xp_Y_XYZp, vec3( 1e-6, 1e-6, 1e-6 ) );\n vec4 vResult;\n vResult.xy = Xp_Y_XYZp.xy / Xp_Y_XYZp.z;\n float Le = 2.0 * log2(Xp_Y_XYZp.y) + 127.0;\n vResult.w = fract( Le );\n vResult.z = ( Le - ( floor( vResult.w * 255.0 ) ) / 255.0 ) / 255.0;\n return vResult;\n}\nconst mat3 cLogLuvInverseM = mat3( 6.0014, -2.7008, -1.7996, -1.3320, 3.1029, -5.7721, 0.3008, -1.0882, 5.6268 );\nvec4 LogLuvToLinear( in vec4 value ) {\n float Le = value.z * 255.0 + value.w;\n vec3 Xp_Y_XYZp;\n Xp_Y_XYZp.y = exp2( ( Le - 127.0 ) / 2.0 );\n Xp_Y_XYZp.z = Xp_Y_XYZp.y / value.y;\n Xp_Y_XYZp.x = value.x * Xp_Y_XYZp.z;\n vec3 vRGB = cLogLuvInverseM * Xp_Y_XYZp.rgb;\n return vec4( max( vRGB, 0.0 ), 1.0 );\n}";
var envmap_fragment = "#ifdef USE_ENVMAP\n #ifdef ENV_WORLDPOS\n vec3 cameraToFrag;\n \n if ( isOrthographic ) {\n cameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n } else {\n cameraToFrag = normalize( vWorldPosition - cameraPosition );\n }\n vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n #ifdef ENVMAP_MODE_REFLECTION\n vec3 reflectVec = reflect( cameraToFrag, worldNormal );\n #else\n vec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );\n #endif\n #else\n vec3 reflectVec = vReflect;\n #endif\n #ifdef ENVMAP_TYPE_CUBE\n vec4 envColor = textureCube( envMap, vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );\n #elif defined( ENVMAP_TYPE_CUBE_UV )\n vec4 envColor = textureCubeUV( envMap, reflectVec, 0.0 );\n #elif defined( ENVMAP_TYPE_EQUIREC )\n vec2 sampleUV;\n reflectVec = normalize( reflectVec );\n sampleUV.y = asin( clamp( reflectVec.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n sampleUV.x = atan( reflectVec.z, reflectVec.x ) * RECIPROCAL_PI2 + 0.5;\n vec4 envColor = texture2D( envMap, sampleUV );\n #elif defined( ENVMAP_TYPE_SPHERE )\n reflectVec = normalize( reflectVec );\n vec3 reflectView = normalize( ( viewMatrix * vec4( reflectVec, 0.0 ) ).xyz + vec3( 0.0, 0.0, 1.0 ) );\n vec4 envColor = texture2D( envMap, reflectView.xy * 0.5 + 0.5 );\n #else\n vec4 envColor = vec4( 0.0 );\n #endif\n #ifndef ENVMAP_TYPE_CUBE_UV\n envColor = envMapTexelToLinear( envColor );\n #endif\n #ifdef ENVMAP_BLENDING_MULTIPLY\n outgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );\n #elif defined( ENVMAP_BLENDING_MIX )\n outgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );\n #elif defined( ENVMAP_BLENDING_ADD )\n outgoingLight += envColor.xyz * specularStrength * reflectivity;\n #endif\n#endif";
var envmap_common_pars_fragment = "#ifdef USE_ENVMAP\n uniform float envMapIntensity;\n uniform float flipEnvMap;\n uniform int maxMipLevel;\n #ifdef ENVMAP_TYPE_CUBE\n uniform samplerCube envMap;\n #else\n uniform sampler2D envMap;\n #endif\n \n#endif";
var envmap_pars_fragment = "#ifdef USE_ENVMAP\n uniform float reflectivity;\n #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )\n #define ENV_WORLDPOS\n #endif\n #ifdef ENV_WORLDPOS\n varying vec3 vWorldPosition;\n uniform float refractionRatio;\n #else\n varying vec3 vReflect;\n #endif\n#endif";
var envmap_pars_vertex = "#ifdef USE_ENVMAP\n #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) ||defined( PHONG )\n #define ENV_WORLDPOS\n #endif\n #ifdef ENV_WORLDPOS\n \n varying vec3 vWorldPosition;\n #else\n varying vec3 vReflect;\n uniform float refractionRatio;\n #endif\n#endif";
var envmap_vertex = "#ifdef USE_ENVMAP\n #ifdef ENV_WORLDPOS\n vWorldPosition = worldPosition.xyz;\n #else\n vec3 cameraToVertex;\n if ( isOrthographic ) { \n cameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n } else {\n cameraToVertex = normalize( worldPosition.xyz - cameraPosition );\n }\n vec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n #ifdef ENVMAP_MODE_REFLECTION\n vReflect = reflect( cameraToVertex, worldNormal );\n #else\n vReflect = refract( cameraToVertex, worldNormal, refractionRatio );\n #endif\n #endif\n#endif";
var fog_vertex = "#ifdef USE_FOG\n fogDepth = -mvPosition.z;\n#endif";
var fog_pars_vertex = "#ifdef USE_FOG\n varying float fogDepth;\n#endif";
var fog_fragment = "#ifdef USE_FOG\n #ifdef FOG_EXP2\n float fogFactor = 1.0 - exp( - fogDensity * fogDensity * fogDepth * fogDepth );\n #else\n float fogFactor = smoothstep( fogNear, fogFar, fogDepth );\n #endif\n gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );\n#endif";
var fog_pars_fragment = "#ifdef USE_FOG\n uniform vec3 fogColor;\n varying float fogDepth;\n #ifdef FOG_EXP2\n uniform float fogDensity;\n #else\n uniform float fogNear;\n uniform float fogFar;\n #endif\n#endif";
var gradientmap_pars_fragment = "#ifdef USE_GRADIENTMAP\n uniform sampler2D gradientMap;\n#endif\nvec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {\n float dotNL = dot( normal, lightDirection );\n vec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );\n #ifdef USE_GRADIENTMAP\n return texture2D( gradientMap, coord ).rgb;\n #else\n return ( coord.x < 0.7 ) ? vec3( 0.7 ) : vec3( 1.0 );\n #endif\n}";
var lightmap_fragment = "#ifdef USE_LIGHTMAP\n vec4 lightMapTexel= texture2D( lightMap, vUv2 );\n reflectedLight.indirectDiffuse += PI * lightMapTexelToLinear( lightMapTexel ).rgb * lightMapIntensity;\n#endif";
var lightmap_pars_fragment = "#ifdef USE_LIGHTMAP\n uniform sampler2D lightMap;\n uniform float lightMapIntensity;\n#endif";
var lights_lambert_vertex = "vec3 diffuse = vec3( 1.0 );\nGeometricContext geometry;\ngeometry.position = mvPosition.xyz;\ngeometry.normal = normalize( transformedNormal );\ngeometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( -mvPosition.xyz );\nGeometricContext backGeometry;\nbackGeometry.position = geometry.position;\nbackGeometry.normal = -geometry.normal;\nbackGeometry.viewDir = geometry.viewDir;\nvLightFront = vec3( 0.0 );\nvIndirectFront = vec3( 0.0 );\n#ifdef DOUBLE_SIDED\n vLightBack = vec3( 0.0 );\n vIndirectBack = vec3( 0.0 );\n#endif\nIncidentLight directLight;\nfloat dotNL;\nvec3 directLightColor_Diffuse;\n#if NUM_POINT_LIGHTS > 0\n #pragma unroll_loop\n for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n getPointDirectLightIrradiance( pointLights[ i ], geometry, directLight );\n dotNL = dot( geometry.normal, directLight.direction );\n directLightColor_Diffuse = PI * directLight.color;\n vLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n #ifdef DOUBLE_SIDED\n vLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n #endif\n }\n#endif\n#if NUM_SPOT_LIGHTS > 0\n #pragma unroll_loop\n for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n getSpotDirectLightIrradiance( spotLights[ i ], geometry, directLight );\n dotNL = dot( geometry.normal, directLight.direction );\n directLightColor_Diffuse = PI * directLight.color;\n vLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n #ifdef DOUBLE_SIDED\n vLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n #endif\n }\n#endif\n#if NUM_DIR_LIGHTS > 0\n #pragma unroll_loop\n for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n getDirectionalDirectLightIrradiance( directionalLights[ i ], geometry, directLight );\n dotNL = dot( geometry.normal, directLight.direction );\n directLightColor_Diffuse = PI * directLight.color;\n vLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n #ifdef DOUBLE_SIDED\n vLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n #endif\n }\n#endif\n#if NUM_HEMI_LIGHTS > 0\n #pragma unroll_loop\n for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n vIndirectFront += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );\n #ifdef DOUBLE_SIDED\n vIndirectBack += getHemisphereLightIrradiance( hemisphereLights[ i ], backGeometry );\n #endif\n }\n#endif";
var lights_pars_begin = "uniform bool receiveShadow;\nuniform vec3 ambientLightColor;\nuniform vec3 lightProbe[ 9 ];\nvec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {\n float x = normal.x, y = normal.y, z = normal.z;\n vec3 result = shCoefficients[ 0 ] * 0.886227;\n result += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;\n result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;\n result += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;\n result += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;\n result += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;\n result += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );\n result += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;\n result += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );\n return result;\n}\nvec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in GeometricContext geometry ) {\n vec3 worldNormal = inverseTransformDirection( geometry.normal, viewMatrix );\n vec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );\n return irradiance;\n}\nvec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {\n vec3 irradiance = ambientLightColor;\n #ifndef PHYSICALLY_CORRECT_LIGHTS\n irradiance *= PI;\n #endif\n return irradiance;\n}\n#if NUM_DIR_LIGHTS > 0\n struct DirectionalLight {\n vec3 direction;\n vec3 color;\n int shadow;\n float shadowBias;\n float shadowRadius;\n vec2 shadowMapSize;\n };\n uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];\n void getDirectionalDirectLightIrradiance( const in DirectionalLight directionalLight, const in GeometricContext geometry, out IncidentLight directLight ) {\n directLight.color = directionalLight.color;\n directLight.direction = directionalLight.direction;\n directLight.visible = true;\n }\n#endif\n#if NUM_POINT_LIGHTS > 0\n struct PointLight {\n vec3 position;\n vec3 color;\n float distance;\n float decay;\n int shadow;\n float shadowBias;\n float shadowRadius;\n vec2 shadowMapSize;\n float shadowCameraNear;\n float shadowCameraFar;\n };\n uniform PointLight pointLights[ NUM_POINT_LIGHTS ];\n void getPointDirectLightIrradiance( const in PointLight pointLight, const in GeometricContext geometry, out IncidentLight directLight ) {\n vec3 lVector = pointLight.position - geometry.position;\n directLight.direction = normalize( lVector );\n float lightDistance = length( lVector );\n directLight.color = pointLight.color;\n directLight.color *= punctualLightIntensityToIrradianceFactor( lightDistance, pointLight.distance, pointLight.decay );\n directLight.visible = ( directLight.color != vec3( 0.0 ) );\n }\n#endif\n#if NUM_SPOT_LIGHTS > 0\n struct SpotLight {\n vec3 position;\n vec3 direction;\n vec3 color;\n float distance;\n float decay;\n float coneCos;\n float penumbraCos;\n int shadow;\n float shadowBias;\n float shadowRadius;\n vec2 shadowMapSize;\n };\n uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];\n void getSpotDirectLightIrradiance( const in SpotLight spotLight, const in GeometricContext geometry, out IncidentLight directLight ) {\n vec3 lVector = spotLight.position - geometry.position;\n directLight.direction = normalize( lVector );\n float lightDistance = length( lVector );\n float angleCos = dot( directLight.direction, spotLight.direction );\n if ( angleCos > spotLight.coneCos ) {\n float spotEffect = smoothstep( spotLight.coneCos, spotLight.penumbraCos, angleCos );\n directLight.color = spotLight.color;\n directLight.color *= spotEffect * punctualLightIntensityToIrradianceFactor( lightDistance, spotLight.distance, spotLight.decay );\n directLight.visible = true;\n } else {\n directLight.color = vec3( 0.0 );\n directLight.visible = false;\n }\n }\n#endif\n#if NUM_RECT_AREA_LIGHTS > 0\n struct RectAreaLight {\n vec3 color;\n vec3 position;\n vec3 halfWidth;\n vec3 halfHeight;\n };\n uniform sampler2D ltc_1; uniform sampler2D ltc_2;\n uniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];\n#endif\n#if NUM_HEMI_LIGHTS > 0\n struct HemisphereLight {\n vec3 direction;\n vec3 skyColor;\n vec3 groundColor;\n };\n uniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];\n vec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in GeometricContext geometry ) {\n float dotNL = dot( geometry.normal, hemiLight.direction );\n float hemiDiffuseWeight = 0.5 * dotNL + 0.5;\n vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );\n #ifndef PHYSICALLY_CORRECT_LIGHTS\n irradiance *= PI;\n #endif\n return irradiance;\n }\n#endif";
var envmap_physical_pars_fragment = "#if defined( USE_ENVMAP )\n #ifdef ENVMAP_MODE_REFRACTION\n uniform float refractionRatio;\n #endif\n vec3 getLightProbeIndirectIrradiance( const in GeometricContext geometry, const in int maxMIPLevel ) {\n vec3 worldNormal = inverseTransformDirection( geometry.normal, viewMatrix );\n #ifdef ENVMAP_TYPE_CUBE\n vec3 queryVec = vec3( flipEnvMap * worldNormal.x, worldNormal.yz );\n #ifdef TEXTURE_LOD_EXT\n vec4 envMapColor = textureCubeLodEXT( envMap, queryVec, float( maxMIPLevel ) );\n #else\n vec4 envMapColor = textureCube( envMap, queryVec, float( maxMIPLevel ) );\n #endif\n envMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n #elif defined( ENVMAP_TYPE_CUBE_UV )\n vec4 envMapColor = textureCubeUV( envMap, worldNormal, 1.0 );\n #else\n vec4 envMapColor = vec4( 0.0 );\n #endif\n return PI * envMapColor.rgb * envMapIntensity;\n }\n float getSpecularMIPLevel( const in float roughness, const in int maxMIPLevel ) {\n float maxMIPLevelScalar = float( maxMIPLevel );\n float sigma = PI * roughness * roughness / ( 1.0 + roughness );\n float desiredMIPLevel = maxMIPLevelScalar + log2( sigma );\n return clamp( desiredMIPLevel, 0.0, maxMIPLevelScalar );\n }\n vec3 getLightProbeIndirectRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in int maxMIPLevel ) {\n #ifdef ENVMAP_MODE_REFLECTION\n vec3 reflectVec = reflect( -viewDir, normal );\n reflectVec = normalize( mix( reflectVec, normal, roughness * roughness) );\n #else\n vec3 reflectVec = refract( -viewDir, normal, refractionRatio );\n #endif\n reflectVec = inverseTransformDirection( reflectVec, viewMatrix );\n float specularMIPLevel = getSpecularMIPLevel( roughness, maxMIPLevel );\n #ifdef ENVMAP_TYPE_CUBE\n vec3 queryReflectVec = vec3( flipEnvMap * reflectVec.x, reflectVec.yz );\n #ifdef TEXTURE_LOD_EXT\n vec4 envMapColor = textureCubeLodEXT( envMap, queryReflectVec, specularMIPLevel );\n #else\n vec4 envMapColor = textureCube( envMap, queryReflectVec, specularMIPLevel );\n #endif\n envMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n #elif defined( ENVMAP_TYPE_CUBE_UV )\n vec4 envMapColor = textureCubeUV( envMap, reflectVec, roughness );\n #elif defined( ENVMAP_TYPE_EQUIREC )\n vec2 sampleUV;\n sampleUV.y = asin( clamp( reflectVec.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n sampleUV.x = atan( reflectVec.z, reflectVec.x ) * RECIPROCAL_PI2 + 0.5;\n #ifdef TEXTURE_LOD_EXT\n vec4 envMapColor = texture2DLodEXT( envMap, sampleUV, specularMIPLevel );\n #else\n vec4 envMapColor = texture2D( envMap, sampleUV, specularMIPLevel );\n #endif\n envMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n #elif defined( ENVMAP_TYPE_SPHERE )\n vec3 reflectView = normalize( ( viewMatrix * vec4( reflectVec, 0.0 ) ).xyz + vec3( 0.0,0.0,1.0 ) );\n #ifdef TEXTURE_LOD_EXT\n vec4 envMapColor = texture2DLodEXT( envMap, reflectView.xy * 0.5 + 0.5, specularMIPLevel );\n #else\n vec4 envMapColor = texture2D( envMap, reflectView.xy * 0.5 + 0.5, specularMIPLevel );\n #endif\n envMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n #endif\n return envMapColor.rgb * envMapIntensity;\n }\n#endif";
var lights_toon_fragment = "ToonMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularColor = specular;\nmaterial.specularShininess = shininess;\nmaterial.specularStrength = specularStrength;";
var lights_toon_pars_fragment = "varying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n varying vec3 vNormal;\n#endif\nstruct ToonMaterial {\n vec3 diffuseColor;\n vec3 specularColor;\n float specularShininess;\n float specularStrength;\n};\nvoid RE_Direct_Toon( const in IncidentLight directLight, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n vec3 irradiance = getGradientIrradiance( geometry.normal, directLight.direction ) * directLight.color;\n #ifndef PHYSICALLY_CORRECT_LIGHTS\n irradiance *= PI;\n #endif\n reflectedLight.directDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n reflectedLight.directSpecular += irradiance * BRDF_Specular_BlinnPhong( directLight, geometry, material.specularColor, material.specularShininess ) * material.specularStrength;\n}\nvoid RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n reflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n}\n#define RE_Direct RE_Direct_Toon\n#define RE_IndirectDiffuse RE_IndirectDiffuse_Toon\n#define Material_LightProbeLOD( material ) (0)";
var lights_phong_fragment = "BlinnPhongMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularColor = specular;\nmaterial.specularShininess = shininess;\nmaterial.specularStrength = specularStrength;";
var lights_phong_pars_fragment = "varying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n varying vec3 vNormal;\n#endif\nstruct BlinnPhongMaterial {\n vec3 diffuseColor;\n vec3 specularColor;\n float specularShininess;\n float specularStrength;\n};\nvoid RE_Direct_BlinnPhong( const in IncidentLight directLight, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n float dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n vec3 irradiance = dotNL * directLight.color;\n #ifndef PHYSICALLY_CORRECT_LIGHTS\n irradiance *= PI;\n #endif\n reflectedLight.directDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n reflectedLight.directSpecular += irradiance * BRDF_Specular_BlinnPhong( directLight, geometry, material.specularColor, material.specularShininess ) * material.specularStrength;\n}\nvoid RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n reflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n}\n#define RE_Direct RE_Direct_BlinnPhong\n#define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong\n#define Material_LightProbeLOD( material ) (0)";
var lights_physical_fragment = "PhysicalMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );\nvec3 dxy = max( abs( dFdx( geometryNormal ) ), abs( dFdy( geometryNormal ) ) );\nfloat geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );\nmaterial.specularRoughness = max( roughnessFactor, 0.0525 );material.specularRoughness += geometryRoughness;\nmaterial.specularRoughness = min( material.specularRoughness, 1.0 );\n#ifdef REFLECTIVITY\n material.specularColor = mix( vec3( MAXIMUM_SPECULAR_COEFFICIENT * pow2( reflectivity ) ), diffuseColor.rgb, metalnessFactor );\n#else\n material.specularColor = mix( vec3( DEFAULT_SPECULAR_COEFFICIENT ), diffuseColor.rgb, metalnessFactor );\n#endif\n#ifdef CLEARCOAT\n material.clearcoat = saturate( clearcoat ); material.clearcoatRoughness = max( clearcoatRoughness, 0.0525 );\n material.clearcoatRoughness += geometryRoughness;\n material.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );\n#endif\n#ifdef USE_SHEEN\n material.sheenColor = sheen;\n#endif";
var lights_physical_pars_fragment = "struct PhysicalMaterial {\n vec3 diffuseColor;\n float specularRoughness;\n vec3 specularColor;\n#ifdef CLEARCOAT\n float clearcoat;\n float clearcoatRoughness;\n#endif\n#ifdef USE_SHEEN\n vec3 sheenColor;\n#endif\n};\n#define MAXIMUM_SPECULAR_COEFFICIENT 0.16\n#define DEFAULT_SPECULAR_COEFFICIENT 0.04\nfloat clearcoatDHRApprox( const in float roughness, const in float dotNL ) {\n return DEFAULT_SPECULAR_COEFFICIENT + ( 1.0 - DEFAULT_SPECULAR_COEFFICIENT ) * ( pow( 1.0 - dotNL, 5.0 ) * pow( 1.0 - roughness, 2.0 ) );\n}\n#if NUM_RECT_AREA_LIGHTS > 0\n void RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n vec3 normal = geometry.normal;\n vec3 viewDir = geometry.viewDir;\n vec3 position = geometry.position;\n vec3 lightPos = rectAreaLight.position;\n vec3 halfWidth = rectAreaLight.halfWidth;\n vec3 halfHeight = rectAreaLight.halfHeight;\n vec3 lightColor = rectAreaLight.color;\n float roughness = material.specularRoughness;\n vec3 rectCoords[ 4 ];\n rectCoords[ 0 ] = lightPos + halfWidth - halfHeight; rectCoords[ 1 ] = lightPos - halfWidth - halfHeight;\n rectCoords[ 2 ] = lightPos - halfWidth + halfHeight;\n rectCoords[ 3 ] = lightPos + halfWidth + halfHeight;\n vec2 uv = LTC_Uv( normal, viewDir, roughness );\n vec4 t1 = texture2D( ltc_1, uv );\n vec4 t2 = texture2D( ltc_2, uv );\n mat3 mInv = mat3(\n vec3( t1.x, 0, t1.y ),\n vec3( 0, 1, 0 ),\n vec3( t1.z, 0, t1.w )\n );\n vec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );\n reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );\n reflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );\n }\n#endif\nvoid RE_Direct_Physical( const in IncidentLight directLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n float dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n vec3 irradiance = dotNL * directLight.color;\n #ifndef PHYSICALLY_CORRECT_LIGHTS\n irradiance *= PI;\n #endif\n #ifdef CLEARCOAT\n float ccDotNL = saturate( dot( geometry.clearcoatNormal, directLight.direction ) );\n vec3 ccIrradiance = ccDotNL * directLight.color;\n #ifndef PHYSICALLY_CORRECT_LIGHTS\n ccIrradiance *= PI;\n #endif\n float clearcoatDHR = material.clearcoat * clearcoatDHRApprox( material.clearcoatRoughness, ccDotNL );\n reflectedLight.directSpecular += ccIrradiance * material.clearcoat * BRDF_Specular_GGX( directLight, geometry.viewDir, geometry.clearcoatNormal, vec3( DEFAULT_SPECULAR_COEFFICIENT ), material.clearcoatRoughness );\n #else\n float clearcoatDHR = 0.0;\n #endif\n #ifdef USE_SHEEN\n reflectedLight.directSpecular += ( 1.0 - clearcoatDHR ) * irradiance * BRDF_Specular_Sheen(\n material.specularRoughness,\n directLight.direction,\n geometry,\n material.sheenColor\n );\n #else\n reflectedLight.directSpecular += ( 1.0 - clearcoatDHR ) * irradiance * BRDF_Specular_GGX( directLight, geometry.viewDir, geometry.normal, material.specularColor, material.specularRoughness);\n #endif\n reflectedLight.directDiffuse += ( 1.0 - clearcoatDHR ) * irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n reflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {\n #ifdef CLEARCOAT\n float ccDotNV = saturate( dot( geometry.clearcoatNormal, geometry.viewDir ) );\n reflectedLight.indirectSpecular += clearcoatRadiance * material.clearcoat * BRDF_Specular_GGX_Environment( geometry.viewDir, geometry.clearcoatNormal, vec3( DEFAULT_SPECULAR_COEFFICIENT ), material.clearcoatRoughness );\n float ccDotNL = ccDotNV;\n float clearcoatDHR = material.clearcoat * clearcoatDHRApprox( material.clearcoatRoughness, ccDotNL );\n #else\n float clearcoatDHR = 0.0;\n #endif\n float clearcoatInv = 1.0 - clearcoatDHR;\n vec3 singleScattering = vec3( 0.0 );\n vec3 multiScattering = vec3( 0.0 );\n vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;\n BRDF_Specular_Multiscattering_Environment( geometry, material.specularColor, material.specularRoughness, singleScattering, multiScattering );\n vec3 diffuse = material.diffuseColor * ( 1.0 - ( singleScattering + multiScattering ) );\n reflectedLight.indirectSpecular += clearcoatInv * radiance * singleScattering;\n reflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;\n reflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;\n}\n#define RE_Direct RE_Direct_Physical\n#define RE_Direct_RectArea RE_Direct_RectArea_Physical\n#define RE_IndirectDiffuse RE_IndirectDiffuse_Physical\n#define RE_IndirectSpecular RE_IndirectSpecular_Physical\nfloat computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {\n return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );\n}";
var lights_fragment_begin = "\nGeometricContext geometry;\ngeometry.position = - vViewPosition;\ngeometry.normal = normal;\ngeometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );\n#ifdef CLEARCOAT\n geometry.clearcoatNormal = clearcoatNormal;\n#endif\nIncidentLight directLight;\n#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )\n PointLight pointLight;\n #pragma unroll_loop\n for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n pointLight = pointLights[ i ];\n getPointDirectLightIrradiance( pointLight, geometry, directLight );\n #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )\n directLight.color *= all( bvec3( pointLight.shadow, directLight.visible, receiveShadow ) ) ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;\n #endif\n RE_Direct( directLight, geometry, material, reflectedLight );\n }\n#endif\n#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )\n SpotLight spotLight;\n #pragma unroll_loop\n for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n spotLight = spotLights[ i ];\n getSpotDirectLightIrradiance( spotLight, geometry, directLight );\n #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n directLight.color *= all( bvec3( spotLight.shadow, directLight.visible, receiveShadow ) ) ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;\n #endif\n RE_Direct( directLight, geometry, material, reflectedLight );\n }\n#endif\n#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )\n DirectionalLight directionalLight;\n #pragma unroll_loop\n for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n directionalLight = directionalLights[ i ];\n getDirectionalDirectLightIrradiance( directionalLight, geometry, directLight );\n #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )\n directLight.color *= all( bvec3( directionalLight.shadow, directLight.visible, receiveShadow ) ) ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n #endif\n RE_Direct( directLight, geometry, material, reflectedLight );\n }\n#endif\n#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )\n RectAreaLight rectAreaLight;\n #pragma unroll_loop\n for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {\n rectAreaLight = rectAreaLights[ i ];\n RE_Direct_RectArea( rectAreaLight, geometry, material, reflectedLight );\n }\n#endif\n#if defined( RE_IndirectDiffuse )\n vec3 iblIrradiance = vec3( 0.0 );\n vec3 irradiance = getAmbientLightIrradiance( ambientLightColor );\n irradiance += getLightProbeIrradiance( lightProbe, geometry );\n #if ( NUM_HEMI_LIGHTS > 0 )\n #pragma unroll_loop\n for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );\n }\n #endif\n#endif\n#if defined( RE_IndirectSpecular )\n vec3 radiance = vec3( 0.0 );\n vec3 clearcoatRadiance = vec3( 0.0 );\n#endif";
var lights_fragment_maps = "#if defined( RE_IndirectDiffuse )\n #ifdef USE_LIGHTMAP\n vec4 lightMapTexel= texture2D( lightMap, vUv2 );\n vec3 lightMapIrradiance = lightMapTexelToLinear( lightMapTexel ).rgb * lightMapIntensity;\n #ifndef PHYSICALLY_CORRECT_LIGHTS\n lightMapIrradiance *= PI;\n #endif\n irradiance += lightMapIrradiance;\n #endif\n #if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )\n iblIrradiance += getLightProbeIndirectIrradiance( geometry, maxMipLevel );\n #endif\n#endif\n#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )\n radiance += getLightProbeIndirectRadiance( geometry.viewDir, geometry.normal, material.specularRoughness, maxMipLevel );\n #ifdef CLEARCOAT\n clearcoatRadiance += getLightProbeIndirectRadiance( geometry.viewDir, geometry.clearcoatNormal, material.clearcoatRoughness, maxMipLevel );\n #endif\n#endif";
var lights_fragment_end = "#if defined( RE_IndirectDiffuse )\n RE_IndirectDiffuse( irradiance, geometry, material, reflectedLight );\n#endif\n#if defined( RE_IndirectSpecular )\n RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometry, material, reflectedLight );\n#endif";
var logdepthbuf_fragment = "#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\n gl_FragDepthEXT = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;\n#endif";
var logdepthbuf_pars_fragment = "#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\n uniform float logDepthBufFC;\n varying float vFragDepth;\n varying float vIsPerspective;\n#endif";
var logdepthbuf_pars_vertex = "#ifdef USE_LOGDEPTHBUF\n #ifdef USE_LOGDEPTHBUF_EXT\n varying float vFragDepth;\n varying float vIsPerspective;\n #else\n uniform float logDepthBufFC;\n #endif\n#endif";
var logdepthbuf_vertex = "#ifdef USE_LOGDEPTHBUF\n #ifdef USE_LOGDEPTHBUF_EXT\n vFragDepth = 1.0 + gl_Position.w;\n vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );\n #else\n if ( isPerspectiveMatrix( projectionMatrix ) ) {\n gl_Position.z = log2( max( EPSILON, gl_Position.w + 1.0 ) ) * logDepthBufFC - 1.0;\n gl_Position.z *= gl_Position.w;\n }\n #endif\n#endif";
var map_fragment = "#ifdef USE_MAP\n vec4 texelColor = texture2D( map, vUv );\n texelColor = mapTexelToLinear( texelColor );\n diffuseColor *= texelColor;\n#endif";
var map_pars_fragment = "#ifdef USE_MAP\n uniform sampler2D map;\n#endif";
var map_particle_fragment = "#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n vec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;\n#endif\n#ifdef USE_MAP\n vec4 mapTexel = texture2D( map, uv );\n diffuseColor *= mapTexelToLinear( mapTexel );\n#endif\n#ifdef USE_ALPHAMAP\n diffuseColor.a *= texture2D( alphaMap, uv ).g;\n#endif";
var map_particle_pars_fragment = "#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n uniform mat3 uvTransform;\n#endif\n#ifdef USE_MAP\n uniform sampler2D map;\n#endif\n#ifdef USE_ALPHAMAP\n uniform sampler2D alphaMap;\n#endif";
var metalnessmap_fragment = "float metalnessFactor = metalness;\n#ifdef USE_METALNESSMAP\n vec4 texelMetalness = texture2D( metalnessMap, vUv );\n metalnessFactor *= texelMetalness.b;\n#endif";
var metalnessmap_pars_fragment = "#ifdef USE_METALNESSMAP\n uniform sampler2D metalnessMap;\n#endif";
var morphnormal_vertex = "#ifdef USE_MORPHNORMALS\n objectNormal *= morphTargetBaseInfluence;\n objectNormal += morphNormal0 * morphTargetInfluences[ 0 ];\n objectNormal += morphNormal1 * morphTargetInfluences[ 1 ];\n objectNormal += morphNormal2 * morphTargetInfluences[ 2 ];\n objectNormal += morphNormal3 * morphTargetInfluences[ 3 ];\n#endif";
var morphtarget_pars_vertex = "#ifdef USE_MORPHTARGETS\n uniform float morphTargetBaseInfluence;\n #ifndef USE_MORPHNORMALS\n uniform float morphTargetInfluences[ 8 ];\n #else\n uniform float morphTargetInfluences[ 4 ];\n #endif\n#endif";
var morphtarget_vertex = "#ifdef USE_MORPHTARGETS\n transformed *= morphTargetBaseInfluence;\n transformed += morphTarget0 * morphTargetInfluences[ 0 ];\n transformed += morphTarget1 * morphTargetInfluences[ 1 ];\n transformed += morphTarget2 * morphTargetInfluences[ 2 ];\n transformed += morphTarget3 * morphTargetInfluences[ 3 ];\n #ifndef USE_MORPHNORMALS\n transformed += morphTarget4 * morphTargetInfluences[ 4 ];\n transformed += morphTarget5 * morphTargetInfluences[ 5 ];\n transformed += morphTarget6 * morphTargetInfluences[ 6 ];\n transformed += morphTarget7 * morphTargetInfluences[ 7 ];\n #endif\n#endif";
var normal_fragment_begin = "#ifdef FLAT_SHADED\n vec3 fdx = vec3( dFdx( vViewPosition.x ), dFdx( vViewPosition.y ), dFdx( vViewPosition.z ) );\n vec3 fdy = vec3( dFdy( vViewPosition.x ), dFdy( vViewPosition.y ), dFdy( vViewPosition.z ) );\n vec3 normal = normalize( cross( fdx, fdy ) );\n#else\n vec3 normal = normalize( vNormal );\n #ifdef DOUBLE_SIDED\n normal = normal * ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n #endif\n #ifdef USE_TANGENT\n vec3 tangent = normalize( vTangent );\n vec3 bitangent = normalize( vBitangent );\n #ifdef DOUBLE_SIDED\n tangent = tangent * ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n bitangent = bitangent * ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n #endif\n #if defined( TANGENTSPACE_NORMALMAP ) || defined( USE_CLEARCOAT_NORMALMAP )\n mat3 vTBN = mat3( tangent, bitangent, normal );\n #endif\n #endif\n#endif\nvec3 geometryNormal = normal;";
var normal_fragment_maps = "#ifdef OBJECTSPACE_NORMALMAP\n normal = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;\n #ifdef FLIP_SIDED\n normal = - normal;\n #endif\n #ifdef DOUBLE_SIDED\n normal = normal * ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n #endif\n normal = normalize( normalMatrix * normal );\n#elif defined( TANGENTSPACE_NORMALMAP )\n vec3 mapN = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;\n mapN.xy *= normalScale;\n #ifdef USE_TANGENT\n normal = normalize( vTBN * mapN );\n #else\n normal = perturbNormal2Arb( -vViewPosition, normal, mapN );\n #endif\n#elif defined( USE_BUMPMAP )\n normal = perturbNormalArb( -vViewPosition, normal, dHdxy_fwd() );\n#endif";
var normalmap_pars_fragment = "#ifdef USE_NORMALMAP\n uniform sampler2D normalMap;\n uniform vec2 normalScale;\n#endif\n#ifdef OBJECTSPACE_NORMALMAP\n uniform mat3 normalMatrix;\n#endif\n#if ! defined ( USE_TANGENT ) && ( defined ( TANGENTSPACE_NORMALMAP ) || defined ( USE_CLEARCOAT_NORMALMAP ) )\n vec3 perturbNormal2Arb( vec3 eye_pos, vec3 surf_norm, vec3 mapN ) {\n vec3 q0 = vec3( dFdx( eye_pos.x ), dFdx( eye_pos.y ), dFdx( eye_pos.z ) );\n vec3 q1 = vec3( dFdy( eye_pos.x ), dFdy( eye_pos.y ), dFdy( eye_pos.z ) );\n vec2 st0 = dFdx( vUv.st );\n vec2 st1 = dFdy( vUv.st );\n float scale = sign( st1.t * st0.s - st0.t * st1.s );\n vec3 S = normalize( ( q0 * st1.t - q1 * st0.t ) * scale );\n vec3 T = normalize( ( - q0 * st1.s + q1 * st0.s ) * scale );\n vec3 N = normalize( surf_norm );\n mat3 tsn = mat3( S, T, N );\n mapN.xy *= ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n return normalize( tsn * mapN );\n }\n#endif";
var clearcoat_normal_fragment_begin = "#ifdef CLEARCOAT\n vec3 clearcoatNormal = geometryNormal;\n#endif";
var clearcoat_normal_fragment_maps = "#ifdef USE_CLEARCOAT_NORMALMAP\n vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vUv ).xyz * 2.0 - 1.0;\n clearcoatMapN.xy *= clearcoatNormalScale;\n #ifdef USE_TANGENT\n clearcoatNormal = normalize( vTBN * clearcoatMapN );\n #else\n clearcoatNormal = perturbNormal2Arb( - vViewPosition, clearcoatNormal, clearcoatMapN );\n #endif\n#endif";
var clearcoat_normalmap_pars_fragment = "#ifdef USE_CLEARCOAT_NORMALMAP\n uniform sampler2D clearcoatNormalMap;\n uniform vec2 clearcoatNormalScale;\n#endif";
var packing = "vec3 packNormalToRGB( const in vec3 normal ) {\n return normalize( normal ) * 0.5 + 0.5;\n}\nvec3 unpackRGBToNormal( const in vec3 rgb ) {\n return 2.0 * rgb.xyz - 1.0;\n}\nconst float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;\nconst vec3 PackFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );\nconst vec4 UnpackFactors = UnpackDownscale / vec4( PackFactors, 1. );\nconst float ShiftRight8 = 1. / 256.;\nvec4 packDepthToRGBA( const in float v ) {\n vec4 r = vec4( fract( v * PackFactors ), v );\n r.yzw -= r.xyz * ShiftRight8; return r * PackUpscale;\n}\nfloat unpackRGBAToDepth( const in vec4 v ) {\n return dot( v, UnpackFactors );\n}\nvec4 pack2HalfToRGBA( vec2 v ) {\n vec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ));\n return vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w);\n}\nvec2 unpackRGBATo2Half( vec4 v ) {\n return vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );\n}\nfloat viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {\n return ( viewZ + near ) / ( near - far );\n}\nfloat orthographicDepthToViewZ( const in float linearClipZ, const in float near, const in float far ) {\n return linearClipZ * ( near - far ) - near;\n}\nfloat viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {\n return (( near + viewZ ) * far ) / (( far - near ) * viewZ );\n}\nfloat perspectiveDepthToViewZ( const in float invClipZ, const in float near, const in float far ) {\n return ( near * far ) / ( ( far - near ) * invClipZ - far );\n}";
var premultiplied_alpha_fragment = "#ifdef PREMULTIPLIED_ALPHA\n gl_FragColor.rgb *= gl_FragColor.a;\n#endif";
var project_vertex = "vec4 mvPosition = vec4( transformed, 1.0 );\n#ifdef USE_INSTANCING\n mvPosition = instanceMatrix * mvPosition;\n#endif\nmvPosition = modelViewMatrix * mvPosition;\ngl_Position = projectionMatrix * mvPosition;";
var dithering_fragment = "#ifdef DITHERING\n gl_FragColor.rgb = dithering( gl_FragColor.rgb );\n#endif";
var dithering_pars_fragment = "#ifdef DITHERING\n vec3 dithering( vec3 color ) {\n float grid_position = rand( gl_FragCoord.xy );\n vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );\n dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );\n return color + dither_shift_RGB;\n }\n#endif";
var roughnessmap_fragment = "float roughnessFactor = roughness;\n#ifdef USE_ROUGHNESSMAP\n vec4 texelRoughness = texture2D( roughnessMap, vUv );\n roughnessFactor *= texelRoughness.g;\n#endif";
var roughnessmap_pars_fragment = "#ifdef USE_ROUGHNESSMAP\n uniform sampler2D roughnessMap;\n#endif";
var shadowmap_pars_fragment = "#ifdef USE_SHADOWMAP\n #if NUM_DIR_LIGHT_SHADOWS > 0\n uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];\n varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n #endif\n #if NUM_SPOT_LIGHT_SHADOWS > 0\n uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];\n varying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHT_SHADOWS ];\n #endif\n #if NUM_POINT_LIGHT_SHADOWS > 0\n uniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];\n varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n #endif\n float texture2DCompare( sampler2D depths, vec2 uv, float compare ) {\n return step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );\n }\n vec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {\n return unpackRGBATo2Half( texture2D( shadow, uv ) );\n }\n float VSMShadow (sampler2D shadow, vec2 uv, float compare ){\n float occlusion = 1.0;\n vec2 distribution = texture2DDistribution( shadow, uv );\n float hard_shadow = step( compare , distribution.x );\n if (hard_shadow != 1.0 ) {\n float distance = compare - distribution.x ;\n float variance = max( 0.00000, distribution.y * distribution.y );\n float softness_probability = variance / (variance + distance * distance ); softness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 ); occlusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 );\n }\n return occlusion;\n }\n float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n float shadow = 1.0;\n shadowCoord.xyz /= shadowCoord.w;\n shadowCoord.z += shadowBias;\n bvec4 inFrustumVec = bvec4 ( shadowCoord.x >= 0.0, shadowCoord.x <= 1.0, shadowCoord.y >= 0.0, shadowCoord.y <= 1.0 );\n bool inFrustum = all( inFrustumVec );\n bvec2 frustumTestVec = bvec2( inFrustum, shadowCoord.z <= 1.0 );\n bool frustumTest = all( frustumTestVec );\n if ( frustumTest ) {\n #if defined( SHADOWMAP_TYPE_PCF )\n vec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n float dx0 = - texelSize.x * shadowRadius;\n float dy0 = - texelSize.y * shadowRadius;\n float dx1 = + texelSize.x * shadowRadius;\n float dy1 = + texelSize.y * shadowRadius;\n float dx2 = dx0 / 2.0;\n float dy2 = dy0 / 2.0;\n float dx3 = dx1 / 2.0;\n float dy3 = dy1 / 2.0;\n shadow = (\n texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +\n texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +\n texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +\n texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +\n texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +\n texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +\n texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +\n texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +\n texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +\n texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +\n texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +\n texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +\n texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +\n texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +\n texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +\n texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +\n texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )\n ) * ( 1.0 / 17.0 );\n #elif defined( SHADOWMAP_TYPE_PCF_SOFT )\n vec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n float dx = texelSize.x;\n float dy = texelSize.y;\n vec2 uv = shadowCoord.xy;\n vec2 f = fract( uv * shadowMapSize + 0.5 );\n uv -= f * texelSize;\n shadow = (\n texture2DCompare( shadowMap, uv, shadowCoord.z ) +\n texture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +\n texture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +\n texture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +\n mix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ), \n texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),\n f.x ) +\n mix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ), \n texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),\n f.x ) +\n mix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ), \n texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),\n f.y ) +\n mix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ), \n texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),\n f.y ) +\n mix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ), \n texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),\n f.x ),\n mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ), \n texture2DCompare( shadowMap, uv + + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),\n f.x ),\n f.y )\n ) * ( 1.0 / 9.0 );\n #elif defined( SHADOWMAP_TYPE_VSM )\n shadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );\n #else\n shadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );\n #endif\n }\n return shadow;\n }\n vec2 cubeToUV( vec3 v, float texelSizeY ) {\n vec3 absV = abs( v );\n float scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );\n absV *= scaleToCube;\n v *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );\n vec2 planar = v.xy;\n float almostATexel = 1.5 * texelSizeY;\n float almostOne = 1.0 - almostATexel;\n if ( absV.z >= almostOne ) {\n if ( v.z > 0.0 )\n planar.x = 4.0 - v.x;\n } else if ( absV.x >= almostOne ) {\n float signX = sign( v.x );\n planar.x = v.z * signX + 2.0 * signX;\n } else if ( absV.y >= almostOne ) {\n float signY = sign( v.y );\n planar.x = v.x + 2.0 * signY + 2.0;\n planar.y = v.z * signY - 2.0;\n }\n return vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );\n }\n float getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {\n vec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );\n vec3 lightToPosition = shadowCoord.xyz;\n float dp = ( length( lightToPosition ) - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear ); dp += shadowBias;\n vec3 bd3D = normalize( lightToPosition );\n #if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )\n vec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;\n return (\n texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +\n texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +\n texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +\n texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +\n texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +\n texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +\n texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +\n texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +\n texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )\n ) * ( 1.0 / 9.0 );\n #else\n return texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );\n #endif\n }\n#endif";
var shadowmap_pars_vertex = "#ifdef USE_SHADOWMAP\n #if NUM_DIR_LIGHT_SHADOWS > 0\n uniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];\n varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n #endif\n #if NUM_SPOT_LIGHT_SHADOWS > 0\n uniform mat4 spotShadowMatrix[ NUM_SPOT_LIGHT_SHADOWS ];\n varying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHT_SHADOWS ];\n #endif\n #if NUM_POINT_LIGHT_SHADOWS > 0\n uniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];\n varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n #endif\n#endif";
var shadowmap_vertex = "#ifdef USE_SHADOWMAP\n #if NUM_DIR_LIGHT_SHADOWS > 0\n #pragma unroll_loop\n for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * worldPosition;\n }\n #endif\n #if NUM_SPOT_LIGHT_SHADOWS > 0\n #pragma unroll_loop\n for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {\n vSpotShadowCoord[ i ] = spotShadowMatrix[ i ] * worldPosition;\n }\n #endif\n #if NUM_POINT_LIGHT_SHADOWS > 0\n #pragma unroll_loop\n for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n vPointShadowCoord[ i ] = pointShadowMatrix[ i ] * worldPosition;\n }\n #endif\n#endif";
var shadowmask_pars_fragment = "float getShadowMask() {\n float shadow = 1.0;\n #ifdef USE_SHADOWMAP\n #if NUM_DIR_LIGHT_SHADOWS > 0\n DirectionalLight directionalLight;\n #pragma unroll_loop\n for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n directionalLight = directionalLights[ i ];\n shadow *= all( bvec2( directionalLight.shadow, receiveShadow ) ) ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n }\n #endif\n #if NUM_SPOT_LIGHT_SHADOWS > 0\n SpotLight spotLight;\n #pragma unroll_loop\n for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {\n spotLight = spotLights[ i ];\n shadow *= all( bvec2( spotLight.shadow, receiveShadow ) ) ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;\n }\n #endif\n #if NUM_POINT_LIGHT_SHADOWS > 0\n PointLight pointLight;\n #pragma unroll_loop\n for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n pointLight = pointLights[ i ];\n shadow *= all( bvec2( pointLight.shadow, receiveShadow ) ) ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;\n }\n #endif\n #endif\n return shadow;\n}";
var skinbase_vertex = "#ifdef USE_SKINNING\n mat4 boneMatX = getBoneMatrix( skinIndex.x );\n mat4 boneMatY = getBoneMatrix( skinIndex.y );\n mat4 boneMatZ = getBoneMatrix( skinIndex.z );\n mat4 boneMatW = getBoneMatrix( skinIndex.w );\n#endif";
var skinning_pars_vertex = "#ifdef USE_SKINNING\n uniform mat4 bindMatrix;\n uniform mat4 bindMatrixInverse;\n #ifdef BONE_TEXTURE\n uniform highp sampler2D boneTexture;\n uniform int boneTextureSize;\n mat4 getBoneMatrix( const in float i ) {\n float j = i * 4.0;\n float x = mod( j, float( boneTextureSize ) );\n float y = floor( j / float( boneTextureSize ) );\n float dx = 1.0 / float( boneTextureSize );\n float dy = 1.0 / float( boneTextureSize );\n y = dy * ( y + 0.5 );\n vec4 v1 = texture2D( boneTexture, vec2( dx * ( x + 0.5 ), y ) );\n vec4 v2 = texture2D( boneTexture, vec2( dx * ( x + 1.5 ), y ) );\n vec4 v3 = texture2D( boneTexture, vec2( dx * ( x + 2.5 ), y ) );\n vec4 v4 = texture2D( boneTexture, vec2( dx * ( x + 3.5 ), y ) );\n mat4 bone = mat4( v1, v2, v3, v4 );\n return bone;\n }\n #else\n uniform mat4 boneMatrices[ MAX_BONES ];\n mat4 getBoneMatrix( const in float i ) {\n mat4 bone = boneMatrices[ int(i) ];\n return bone;\n }\n #endif\n#endif";
var skinning_vertex = "#ifdef USE_SKINNING\n vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );\n vec4 skinned = vec4( 0.0 );\n skinned += boneMatX * skinVertex * skinWeight.x;\n skinned += boneMatY * skinVertex * skinWeight.y;\n skinned += boneMatZ * skinVertex * skinWeight.z;\n skinned += boneMatW * skinVertex * skinWeight.w;\n transformed = ( bindMatrixInverse * skinned ).xyz;\n#endif";
var skinnormal_vertex = "#ifdef USE_SKINNING\n mat4 skinMatrix = mat4( 0.0 );\n skinMatrix += skinWeight.x * boneMatX;\n skinMatrix += skinWeight.y * boneMatY;\n skinMatrix += skinWeight.z * boneMatZ;\n skinMatrix += skinWeight.w * boneMatW;\n skinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;\n objectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;\n #ifdef USE_TANGENT\n objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;\n #endif\n#endif";
var specularmap_fragment = "float specularStrength;\n#ifdef USE_SPECULARMAP\n vec4 texelSpecular = texture2D( specularMap, vUv );\n specularStrength = texelSpecular.r;\n#else\n specularStrength = 1.0;\n#endif";
var specularmap_pars_fragment = "#ifdef USE_SPECULARMAP\n uniform sampler2D specularMap;\n#endif";
var tonemapping_fragment = "#if defined( TONE_MAPPING )\n gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );\n#endif";
var tonemapping_pars_fragment = "#ifndef saturate\n#define saturate(a) clamp( a, 0.0, 1.0 )\n#endif\nuniform float toneMappingExposure;\nuniform float toneMappingWhitePoint;\nvec3 LinearToneMapping( vec3 color ) {\n return toneMappingExposure * color;\n}\nvec3 ReinhardToneMapping( vec3 color ) {\n color *= toneMappingExposure;\n return saturate( color / ( vec3( 1.0 ) + color ) );\n}\n#define Uncharted2Helper( x ) max( ( ( x * ( 0.15 * x + 0.10 * 0.50 ) + 0.20 * 0.02 ) / ( x * ( 0.15 * x + 0.50 ) + 0.20 * 0.30 ) ) - 0.02 / 0.30, vec3( 0.0 ) )\nvec3 Uncharted2ToneMapping( vec3 color ) {\n color *= toneMappingExposure;\n return saturate( Uncharted2Helper( color ) / Uncharted2Helper( vec3( toneMappingWhitePoint ) ) );\n}\nvec3 OptimizedCineonToneMapping( vec3 color ) {\n color *= toneMappingExposure;\n color = max( vec3( 0.0 ), color - 0.004 );\n return pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );\n}\nvec3 ACESFilmicToneMapping( vec3 color ) {\n color *= toneMappingExposure;\n return saturate( ( color * ( 2.51 * color + 0.03 ) ) / ( color * ( 2.43 * color + 0.59 ) + 0.14 ) );\n}";
var uv_pars_fragment = "#if ( defined( USE_UV ) && ! defined( UVS_VERTEX_ONLY ) )\n varying vec2 vUv;\n#endif";
var uv_pars_vertex = "#ifdef USE_UV\n #ifdef UVS_VERTEX_ONLY\n vec2 vUv;\n #else\n varying vec2 vUv;\n #endif\n uniform mat3 uvTransform;\n#endif";
var uv_vertex = "#ifdef USE_UV\n vUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n#endif";
var uv2_pars_fragment = "#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n varying vec2 vUv2;\n#endif";
var uv2_pars_vertex = "#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n attribute vec2 uv2;\n varying vec2 vUv2;\n uniform mat3 uv2Transform;\n#endif";
var uv2_vertex = "#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n vUv2 = ( uv2Transform * vec3( uv2, 1 ) ).xy;\n#endif";
var worldpos_vertex = "#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP )\n vec4 worldPosition = vec4( transformed, 1.0 );\n #ifdef USE_INSTANCING\n worldPosition = instanceMatrix * worldPosition;\n #endif\n worldPosition = modelMatrix * worldPosition;\n#endif";
var background_frag = "uniform sampler2D t2D;\nvarying vec2 vUv;\nvoid main() {\n vec4 texColor = texture2D( t2D, vUv );\n gl_FragColor = mapTexelToLinear( texColor );\n #include \n #include \n}";
var background_vert = "varying vec2 vUv;\nuniform mat3 uvTransform;\nvoid main() {\n vUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n gl_Position = vec4( position.xy, 1.0, 1.0 );\n}";
var cube_frag = "#include \nuniform float opacity;\nvarying vec3 vWorldDirection;\n#include \nvoid main() {\n vec3 vReflect = vWorldDirection;\n #include \n gl_FragColor = envColor;\n gl_FragColor.a *= opacity;\n #include \n #include \n}";
var cube_vert = "varying vec3 vWorldDirection;\n#include \nvoid main() {\n vWorldDirection = transformDirection( position, modelMatrix );\n #include \n #include \n gl_Position.z = gl_Position.w;\n}";
var depth_frag = "#if DEPTH_PACKING == 3200\n uniform float opacity;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n #include \n vec4 diffuseColor = vec4( 1.0 );\n #if DEPTH_PACKING == 3200\n diffuseColor.a = opacity;\n #endif\n #include \n #include \n #include \n #include \n #if DEPTH_PACKING == 3200\n gl_FragColor = vec4( vec3( 1.0 - gl_FragCoord.z ), opacity );\n #elif DEPTH_PACKING == 3201\n gl_FragColor = packDepthToRGBA( gl_FragCoord.z );\n #endif\n}";
var depth_vert = "#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n #include \n #include \n #ifdef USE_DISPLACEMENTMAP\n #include \n #include \n #include \n #endif\n #include \n #include \n #include \n #include \n #include \n #include \n #include \n}";
var distanceRGBA_frag = "#define DISTANCE\nuniform vec3 referencePosition;\nuniform float nearDistance;\nuniform float farDistance;\nvarying vec3 vWorldPosition;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main () {\n #include \n vec4 diffuseColor = vec4( 1.0 );\n #include \n #include \n #include \n float dist = length( vWorldPosition - referencePosition );\n dist = ( dist - nearDistance ) / ( farDistance - nearDistance );\n dist = saturate( dist );\n gl_FragColor = packDepthToRGBA( dist );\n}";
var distanceRGBA_vert = "#define DISTANCE\nvarying vec3 vWorldPosition;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n #include \n #include \n #ifdef USE_DISPLACEMENTMAP\n #include \n #include \n #include \n #endif\n #include \n #include \n #include \n #include \n #include \n #include \n #include \n vWorldPosition = worldPosition.xyz;\n}";
var equirect_frag = "uniform sampler2D tEquirect;\nvarying vec3 vWorldDirection;\n#include \nvoid main() {\n vec3 direction = normalize( vWorldDirection );\n vec2 sampleUV;\n sampleUV.y = asin( clamp( direction.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n sampleUV.x = atan( direction.z, direction.x ) * RECIPROCAL_PI2 + 0.5;\n vec4 texColor = texture2D( tEquirect, sampleUV );\n gl_FragColor = mapTexelToLinear( texColor );\n #include \n #include \n}";
var equirect_vert = "varying vec3 vWorldDirection;\n#include \nvoid main() {\n vWorldDirection = transformDirection( position, modelMatrix );\n #include \n #include \n}";
var linedashed_frag = "uniform vec3 diffuse;\nuniform float opacity;\nuniform float dashSize;\nuniform float totalSize;\nvarying float vLineDistance;\n#include \n#include \n#include \n#include \n#include \nvoid main() {\n #include \n if ( mod( vLineDistance, totalSize ) > dashSize ) {\n discard;\n }\n vec3 outgoingLight = vec3( 0.0 );\n vec4 diffuseColor = vec4( diffuse, opacity );\n #include \n #include \n outgoingLight = diffuseColor.rgb;\n gl_FragColor = vec4( outgoingLight, diffuseColor.a );\n #include \n #include \n #include \n #include \n}";
var linedashed_vert = "uniform float scale;\nattribute float lineDistance;\nvarying float vLineDistance;\n#include \n#include \n#include \n#include \n#include \nvoid main() {\n #include \n vLineDistance = scale * lineDistance;\n vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\n gl_Position = projectionMatrix * mvPosition;\n #include \n #include \n #include \n}";
var meshbasic_frag = "uniform vec3 diffuse;\nuniform float opacity;\n#ifndef FLAT_SHADED\n varying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n #include \n vec4 diffuseColor = vec4( diffuse, opacity );\n #include \n #include \n #include \n #include \n #include \n #include \n ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n #ifdef USE_LIGHTMAP\n \n vec4 lightMapTexel= texture2D( lightMap, vUv2 );\n reflectedLight.indirectDiffuse += lightMapTexelToLinear( lightMapTexel ).rgb * lightMapIntensity;\n #else\n reflectedLight.indirectDiffuse += vec3( 1.0 );\n #endif\n #include \n reflectedLight.indirectDiffuse *= diffuseColor.rgb;\n vec3 outgoingLight = reflectedLight.indirectDiffuse;\n #include \n gl_FragColor = vec4( outgoingLight, diffuseColor.a );\n #include \n #include \n #include \n #include \n}";
var meshbasic_vert = "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n #include \n #include \n #include \n #include \n #ifdef USE_ENVMAP\n #include \n #include \n #include \n #include \n #endif\n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n}";
var meshlambert_frag = "uniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\nvarying vec3 vLightFront;\nvarying vec3 vIndirectFront;\n#ifdef DOUBLE_SIDED\n varying vec3 vLightBack;\n varying vec3 vIndirectBack;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n #include \n vec4 diffuseColor = vec4( diffuse, opacity );\n ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n vec3 totalEmissiveRadiance = emissive;\n #include \n #include \n #include \n #include \n #include \n #include \n #include \n reflectedLight.indirectDiffuse = getAmbientLightIrradiance( ambientLightColor );\n #ifdef DOUBLE_SIDED\n reflectedLight.indirectDiffuse += ( gl_FrontFacing ) ? vIndirectFront : vIndirectBack;\n #else\n reflectedLight.indirectDiffuse += vIndirectFront;\n #endif\n #include \n reflectedLight.indirectDiffuse *= BRDF_Diffuse_Lambert( diffuseColor.rgb );\n #ifdef DOUBLE_SIDED\n reflectedLight.directDiffuse = ( gl_FrontFacing ) ? vLightFront : vLightBack;\n #else\n reflectedLight.directDiffuse = vLightFront;\n #endif\n reflectedLight.directDiffuse *= BRDF_Diffuse_Lambert( diffuseColor.rgb ) * getShadowMask();\n #include \n vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n #include \n gl_FragColor = vec4( outgoingLight, diffuseColor.a );\n #include \n #include \n #include \n #include \n #include \n}";
var meshlambert_vert = "#define LAMBERT\nvarying vec3 vLightFront;\nvarying vec3 vIndirectFront;\n#ifdef DOUBLE_SIDED\n varying vec3 vLightBack;\n varying vec3 vIndirectBack;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n}";
var meshmatcap_frag = "#define MATCAP\nuniform vec3 diffuse;\nuniform float opacity;\nuniform sampler2D matcap;\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n varying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n #include \n vec4 diffuseColor = vec4( diffuse, opacity );\n #include \n #include \n #include \n #include \n #include \n #include \n vec3 viewDir = normalize( vViewPosition );\n vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );\n vec3 y = cross( viewDir, x );\n vec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;\n #ifdef USE_MATCAP\n vec4 matcapColor = texture2D( matcap, uv );\n matcapColor = matcapTexelToLinear( matcapColor );\n #else\n vec4 matcapColor = vec4( 1.0 );\n #endif\n vec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;\n gl_FragColor = vec4( outgoingLight, diffuseColor.a );\n #include \n #include \n #include \n #include \n}";
var meshmatcap_vert = "#define MATCAP\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n varying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include