您好我一直在尝试存储从obj文件加载的对象。基本上我正在尝试创建新的网格并将其存储在网格变量中,以便稍后在Javascript中我可以引用该对象并更改其属性。但是,当我声明这个网格变量并指定一个网格的子节点时,在加载结束后,该子节点消失,我的网格中没有任何内容。有没有办法从加载的网格创建新网格并存储它们?谢谢!
var mesh = new THREE.Mesh();
//loading the model
var loader = new THREE.OBJLoader(manager);
loader.load('models/stuff2.obj', function(object){
//adding object into the scene
object.name = "trying";
object.traverse(function(child){
if(child instanceof THREE.Mesh){
child.material.map = texture;
}
});
object.position.set(0,0,0);
scene.add(mesh);
});
console.log(mesh);
答案 0 :(得分:0)
您正在加载网格,因此您不需要将网格声明为网格。您只需将它用作加载对象的容器。
var mesh;
//loading the model
var loader = new THREE.OBJLoader(manager);
loader.load('models/stuff2.obj', function(object){
//adding object into the scene
object.name = "trying";
object.traverse(function(child){
if(child instanceof THREE.Mesh){
child.material.map = texture;
}
});
object.position.set(0,0,0);
scene.add(object);
mesh = object;
});
// then use it later
$("#my3dworldcontrol").click(function(){
console.log(mesh);
});
答案 1 :(得分:0)
在函数内......
--Create table to test with and add in values
CREATE TABLE #tbl1 (ReportID int, [date] date, [area] varchar(2), BuildingName varchar(5), [Amount] int)
INSERT INTO #tbl1 VALUES(1, '20130101', 'S1', 'A1-01', 5)
INSERT INTO #tbl1 VALUES(2, '20130101', 'S1', 'A1-03', 5)
INSERT INTO #tbl1 VALUES(3, '20130101', 'S2', 'A1-05', 4)
INSERT INTO #tbl1 VALUES(4, '20130201', 'S2', 'A1-05', 7)
INSERT INTO #tbl1 VALUES(5, '20130201', 'S2', 'A1-03', 9)
INSERT INTO #tbl1 VALUES(6, '20130301', 'S1', 'A1-03', 2)
INSERT INTO #tbl1 VALUES(7, '20130401', 'S2', 'A1-02', 6)
INSERT INTO #tbl1 VALUES(8, '20130501', 'S1', 'A1-01', 7)
INSERT INTO #tbl1 VALUES(9, '20130601', 'S1', 'A1-02', 5)
INSERT INTO #tbl1 VALUES(10, '20130601', 'S1', 'A1-05', 8)
INSERT INTO #tbl1 VALUES(11, '20130601', 'S1', 'A1-01', 5)
--Declare the date variable you mentioned you wanted to "Pass in"
DECLARE @passedInDate date
set @passedInDate = '20130101'
--Here's the code that matters
select [Date], area, BuildingName, Amount
, (SELECT SUM(Amount) from #tbl1 [sq] where sq.area = tbl1.area and sq.BuildingName = tbl1.BuildingName) as [Sum]
from #tbl1 tbl1
where [DATE] = @passedInDate
--Drop testing table
Drop Table #tbl1