0
奇妙な状況browserifyは自分の関数を呼び出すのですか?
私はどうやらそれはBrowserifyによって呼び出される...私によって呼び出されていないTHREE.Vector3.prototype.changeBasis
という名前の関数を持っているが、それでも型エラーを返します!
スタックトレースは、直線1、列246を指します。この行は、Browserifyによって生成されます。
これは、1行目は私のバンドルファイルにどのように見えるかです:
(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
そして、これが、それは以降のカラム246から見て、どのようにです:
t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
質問です:なぜ1行目の呼び出しがあります私の機能..?それはしないでください。
これは、スタックトレースがいっぱいにどのように見えるかです:
TypeError: transformMatrix is undefined[Learn More] tb.js:16065:27
changeBasis file:///C:/Users/Jon/Auchitect/frontend/js/tb.js:16065:27
[90]< file:///C:/Users/Jon/Auchitect/frontend/js/tb.js:16063:48
s file:///C:/Users/Jon/Auchitect/frontend/js/tb.js:1:246
s/< file:///C:/Users/Jon/Auchitect/frontend/js/tb.js:1:305
[86]< file:///C:/Users/Jon/Auchitect/frontend/js/tb.js:15220:1
s file:///C:/Users/Jon/Auchitect/frontend/js/tb.js:1:246
s/< file:///C:/Users/Jon/Auchitect/frontend/js/tb.js:1:305
[85]< file:///C:/Users/Jon/Auchitect/frontend/js/tb.js:14689:20
s file:///C:/Users/Jon/Auchitect/frontend/js/tb.js:1:246
s/< file:///C:/Users/Jon/Auchitect/frontend/js/tb.js:1:305
[5]< file:///C:/Users/Jon/Auchitect/frontend/js/tb.js:878:17
s file:///C:/Users/Jon/Auchitect/frontend/js/tb.js:1:246
s/< file:///C:/Users/Jon/Auchitect/frontend/js/tb.js:1:305
[17]< file:///C:/Users/Jon/Auchitect/frontend/js/tb.js:4528:15
s file:///C:/Users/Jon/Auchitect/frontend/js/tb.js:1:246
s/< file:///C:/Users/Jon/Auchitect/frontend/js/tb.js:1:305
[61]< file:///C:/Users/Jon/Auchitect/frontend/js/tb.js:11972:24
s file:///C:/Users/Jon/Auchitect/frontend/js/tb.js:1:246
s/< file:///C:/Users/Jon/Auchitect/frontend/js/tb.js:1:305
[40]< file:///C:/Users/Jon/Auchitect/frontend/js/tb.js:5947:33
s file:///C:/Users/Jon/Auchitect/frontend/js/tb.js:1:246
s/< file:///C:/Users/Jon/Auchitect/frontend/js/tb.js:1:305
[35]< file:///C:/Users/Jon/Auchitect/frontend/js/tb.js:5109:20
s file:///C:/Users/Jon/Auchitect/frontend/js/tb.js:1:246
e file:///C:/Users/Jon/Auchitect/frontend/js/tb.js:1:425
<anonymous> file:///C:/Users/Jon/Auchitect/frontend/js/tb.js:1:11
関数定義内の二つの第一のラインポイントして、スタックトレースは、ストレート(tb.js
という名前の)私のバンドルファイルの1行目にジャンプします。
これは私が私の関数を定義する方法である:
THREE.Vector3.prototype.changeBasis = function changeBasis(transformMatrix, lb0, lb1, lb2, local_to_global) { // line 163063 in the bundle
if (!local_to_global) { transformMatrix.getInverse(transformMatrix) } // line 163065 in the bundle
return this.applyMatrix3(transformMatrix);
}();
これは私の関数が定義されているファイルです:
"use strict";
var THREE = require('three');
var loadTexture_promise = (texture_path, texture_loader) => {
var texture_promise;
if ( loadTexture_promise.texturePromises_cache[texture_path] !== undefined) {
return loadTexture_promise.texturePromises_cache[texture_path]
}
texture_promise = new Promise(
function(resolve, reject)
{
texture_loader.load(
texture_path,
function (texture) {
// Success callback of TextureLoader
// We're done, so tell the promise it is complete
resolve(texture);
},
function (XmlHttpRequest_instance) {
// Progress callback of TextureLoader
},
function (unknown_parameter) {
// Failure callback of TextureLoader
// Reject the promise with the failure
reject(new Error('Could not load texture ' + texture_path));
}
);
}
);
// add texture_promise to cache:
loadTexture_promise.texturePromises_cache[texture_path] = texture_promise;
return texture_promise;
};
// establish cache object on the loadTexture_promise function:
loadTexture_promise.texturePromises_cache = [];
THREE.PointHelper = function (position = {x:0,y:0,z:0}, size = 20) {
var geometry = new THREE.Geometry();
var material = new THREE.LineBasicMaterial({ vertexColors: THREE.VertexColors });
this.colorX_origo = new THREE.Color(1, 0, 0);
this.colorX_end = new THREE.Color(1, 0.6, 0);
this.colorY_origo = new THREE.Color(0, 1, 0);
this.colorY_end = new THREE.Color(0.6, 1, 0);
this.colorZ_origo = new THREE.Color(0, 0, 1);
this.colorZ_end = new THREE.Color(0, 0.6, 1);
geometry.vertices.push(
new THREE.Vector3(-size, 0, 0), new THREE.Vector3(0, 0, 0),
new THREE.Vector3( size, 0, 0), new THREE.Vector3(0, 0, 0),
new THREE.Vector3(0, -size, 0), new THREE.Vector3(0, 0, 0),
new THREE.Vector3(0, size, 0), new THREE.Vector3(0, 0, 0),
new THREE.Vector3(0, 0, -size), new THREE.Vector3(0, 0, 0),
new THREE.Vector3(0, 0, size), new THREE.Vector3(0, 0, 0)
);
geometry.colors.push(
this.colorX_end, this.colorX_origo, this.colorX_end, this.colorX_origo,
this.colorY_end, this.colorY_origo, this.colorY_end, this.colorY_origo,
this.colorZ_end, this.colorZ_origo, this.colorZ_end, this.colorZ_origo);
THREE.Line.call(this, geometry, material);
this.position.set(position.x, position.y, position.z);
};
THREE.PointHelper.prototype = Object.create(THREE.LineSegments.prototype);
THREE.PointHelper.prototype.constructor = THREE.PointHelper;
var origo = new THREE.Vector3();
THREE.VectorHelper = function (end, color) {
var geometry = new THREE.Geometry();
var material = new THREE.LineBasicMaterial({ vertexColors: THREE.VertexColors });
geometry.vertices.push(origo, end);
if (typeof color !== "undefined") { this.color = new THREE.Color(color ); }
else { this.color = new THREE.Color(0xffffff); }
geometry.colors.push(this.color, this.color);
THREE.Line.call(this, geometry, material);
};
THREE.VectorHelper.prototype = Object.create(THREE.Line.prototype);
THREE.VectorHelper.prototype.constructor = THREE.VectorHelper;
THREE.VectorHelper.prototype.setColor = function(color) {
this.color.set(color);
this.geometry.colorsNeedUpdate = true;
return this
};
THREE.LineHelper = function (start, end, color) {
var geometry = new THREE.Geometry();
var material = new THREE.LineBasicMaterial({ vertexColors: THREE.VertexColors });
geometry.vertices.push(start, end);
if (typeof color !== "undefined") { this.color = new THREE.Color(color ); }
else { this.color = new THREE.Color(0xffffff); }
geometry.colors.push(this.color, this.color);
THREE.Line.call(this, geometry, material);
};
THREE.LineHelper.prototype = Object.create(THREE.Line.prototype);
THREE.LineHelper.prototype.constructor = THREE.LineHelper;
THREE.LineHelper.prototype.setColor = function(color) {
this.color.set(color);
this.geometry.colorsNeedUpdate = true;
return this
};
// fixme: consider having it take a THREE.Plane as argument:
THREE.PlaneHelper = function (planeNormal, planeCenter, size, step, colorCenterLine, colorGrid, debug) {
if (typeof colorGrid === "undefined") { colorGrid = colorCenterLine; }
THREE.GridHelper.call(this, size, step, colorCenterLine, colorGrid);
if (debug) { console.log("this.rotation before quaternion: ", this.rotation.clone()); }
this.position.set(planeCenter.x, planeCenter.y, planeCenter.z);
var standardPlaneNormal = new THREE.Vector3(0, 1, 0);
var quaternion = new THREE.Quaternion().setFromUnitVectors(standardPlaneNormal, planeNormal);
this.rotation.setFromQuaternion(quaternion);
if (debug) {
console.log("quaternion after setFromUnitVectors: ", quaternion.clone());
console.log("this.rotation after quaternion: ", this.rotation.clone()); }
};
THREE.PlaneHelper.prototype = Object.create(THREE.GridHelper.prototype);
THREE.PlaneHelper.prototype.constructor = THREE.PlaneHelper;
THREE.Vector3.prototype.rejectOnVector = function() {
var v1;
return function rejectOnVector(planeNormal) {
if (v1 === undefined) v1 = new THREE.Vector3();
v1.copy(this).projectOnVector(planeNormal);
return this.sub(v1);
};
}();
THREE.Vector3.prototype.changeBasis = function changeBasis(transformMatrix, lb0, lb1, lb2, local_to_global) { // lb = local basis
if (!local_to_global) { transformMatrix.getInverse(transformMatrix) }
return this.applyMatrix3(transformMatrix);
}();
module.exports = {
loadTexture_promise
};
'...}()'は関数呼び出しです。 – melpomene