//加载场景代码
var app = new THING.App({
    // 场景地址
    "url": "http://www.thingjs.com/./uploads/wechat/oLX7p05lsWJZUIxnIWsNXAzJ40X8/scene/管线演示 2",
    //背景设置
    "skyBox": "BlueSky"
});
app.on('load', function () {
    //摄像机位置初始化
    app.camera.position = [0.4374202706634094, 101.92917348318593, 97.06808820543526];
    app.camera.target = [52.75056074670042, -18.885239034825123, -20.619558480451797];
    new THING.widget.Button('水管演示', water);
    new THING.widget.Button('电线演示', electric);
    new THING.widget.Button('燃气演示', gas);
});
function water() {
}
function electric() {
}
function gas() {
}
var line = null;
function buildLine(points, color) {
    line = app.create({
        type: 'PolygonLine',
        points: points,
        style: {
            color: color,
        }
    });
    line.scrollUV = true;
}
function water() {
var waterUnderPoints = [];
buildingOpacity(0.3);
app.query(/building_0/).forEach(
function (parentObj) {
var points = [];
points.push(parentObj.selfToWorld([5, -0.8, 0]));
waterUnderPoints.push(points[0]);
for (var i = 3; i <= 24; i += 3) {
points.push(parentObj.selfToWorld([5, i, 0]));
points.push(parentObj.selfToWorld([5, i, 3]));
points.push(parentObj.selfToWorld([-5, i, 3]));
points.push(parentObj.selfToWorld([-5, i, -3]));
points.push(parentObj.selfToWorld([5, i, -3]));
points.push(parentObj.selfToWorld([5, i, 0]));
}
points.push(parentObj.selfToWorld([5, 24, 0]));
buildLine(points, '#0000FF');
}
);
waterUnderPoints.push([15.32711, -0.79, -55.655339999999999]);
buildLine(waterUnderPoints, '#0000FF');
//renderOrder();
}
function buildingOpacity(num) {
app.query("*").forEach(function (obj) {
obj.style.opacity = num;
});
}
function renderOrder(){
app.query('.PolygonLine').forEach(
function (obj) {
obj.renderOrder = -10000;
}
);
}
function electric() {
    var electricUnderPoints = [];
    buildingOpacity(0.3);
    app.query(/building_0/).forEach(
        function (parentObj) {
            var points = [];
            points.push(parentObj.selfToWorld([3, -0.8, 0]));
            electricUnderPoints.push(points[0]);
            for (var i = 3; i <= 24; i += 2.5) {
                points.push(parentObj.selfToWorld([3, i, 0]));
                points.push(parentObj.selfToWorld([-3, i, 2]));
            }
            points.push(parentObj.selfToWorld([3, 24, 0]));
            buildLine(points, '#00FF00');
            console.log(points);
        }
    );
    electricUnderPoints.push([16.690666, -0.79, -55.115203999999999]);
    buildLine(electricUnderPoints, '#00FF00');
    renderOrder();
}
function gas() {
var gasUnderPoints = [];
buildingOpacity(0.3);
app.query(/building_0/).forEach(
function (parentObj) {
var points = [];
points.push(parentObj.selfToWorld([-6.2, -0.3, 0]));
gasUnderPoints.unshift(points[0]);
for (var i = 3; i <= 24; i += 3) {
points.push(parentObj.selfToWorld([-6.2, i, 0]));
points.push(parentObj.selfToWorld([-6.2, i, 2]));
points.push(parentObj.selfToWorld([6.2, i, 2]));
points.push(parentObj.selfToWorld([6.2, i, -2]));
points.push(parentObj.selfToWorld([-6.2, i, -2]));
points.push(parentObj.selfToWorld([-6.2, i, 0]));
}
points.push(parentObj.selfToWorld([-6.2, 24, 0]));
buildLine(points, '#FF0000');
console.log(points);
}
);
gasUnderPoints.unshift([22.963023600000003, -0.3, 57.8305784]);
buildLine(gasUnderPoints, '#FF0000');
renderOrder();
}
//加载场景代码
var app = new THING.App({
    // 场景地址
    "url": "http://www.thingjs.com/./uploads/wechat/oLX7p05lsWJZUIxnIWsNXAzJ40X8/scene/管线演示 2",
    //背景设置
    "skyBox": "BlueSky"
});
app.on('load', function () {
//摄像机位置初始化
app.camera.position = [0.4374202706634094, 101.92917348318593, 97.06808820543526];
app.camera.target = [52.75056074670042, -18.885239034825123, -20.619558480451797];
new THING.widget.Button('水管演示', water);
new THING.widget.Button('电线演示', electric);
new THING.widget.Button('燃气演示', gas);
});
function water() {
var waterUnderPoints = [];
buildingOpacity(0.3);
app.query(/building_0/).forEach(
function (parentObj) {
var points = [];
points.push(parentObj.selfToWorld([5, -0.8, 0]));
waterUnderPoints.push(points[0]);
for (var i = 3; i <= 24; i += 3) {
points.push(parentObj.selfToWorld([5, i, 0]));
points.push(parentObj.selfToWorld([5, i, 3]));
points.push(parentObj.selfToWorld([-5, i, 3]));
points.push(parentObj.selfToWorld([-5, i, -3]));
points.push(parentObj.selfToWorld([5, i, -3]));
points.push(parentObj.selfToWorld([5, i, 0]));
}
points.push(parentObj.selfToWorld([5, 24, 0]));
buildLine(points, '#0000FF');
}
);
waterUnderPoints.push([15.32711, -0.79, -55.655339999999999]);
buildLine(waterUnderPoints, '#0000FF');
renderOrder();
}
function electric() {
var electricUnderPoints = [];
buildingOpacity(0.3);
app.query(/building_0/).forEach(
function (parentObj) {
var points = [];
points.push(parentObj.selfToWorld([3, -0.8, 0]));
electricUnderPoints.push(points[0]);
for (var i = 3; i <= 24; i += 2.5) {
points.push(parentObj.selfToWorld([3, i, 0]));
points.push(parentObj.selfToWorld([-3, i, 2]));
}
points.push(parentObj.selfToWorld([3, 24, 0]));
buildLine(points, '#00FF00');
console.log(points);
}
);
electricUnderPoints.push([16.690666, -0.79, -55.115203999999999]);
buildLine(electricUnderPoints, '#00FF00');
renderOrder();
}
function gas() {
var gasUnderPoints = [];
buildingOpacity(0.3);
app.query(/building_0/).forEach(
function (parentObj) {
var points = [];
points.push(parentObj.selfToWorld([-6.2, -0.3, 0]));
gasUnderPoints.unshift(points[0]);
for (var i = 3; i <= 24; i += 3) {
points.push(parentObj.selfToWorld([-6.2, i, 0]));
points.push(parentObj.selfToWorld([-6.2, i, 2]));
points.push(parentObj.selfToWorld([6.2, i, 2]));
points.push(parentObj.selfToWorld([6.2, i, -2]));
points.push(parentObj.selfToWorld([-6.2, i, -2]));
points.push(parentObj.selfToWorld([-6.2, i, 0]));
}
points.push(parentObj.selfToWorld([-6.2, 24, 0]));
buildLine(points, '#FF0000');
console.log(points);
}
);
gasUnderPoints.unshift([22.963023600000003, -0.3, 57.8305784]);
buildLine(gasUnderPoints, '#FF0000');
renderOrder();
}
/************************************************************************
function buildingOpacity(num) { app.query("*").forEach(function (obj) { obj.style.opacity = num; }); }
function renderOrder(){ app.query('.PolygonLine').forEach( function (obj) { obj.renderOrder = -10000; } ); }
var line = null; function buildLine(points, color) { line = app.create({ type: 'PolygonLine', points: points, style: { color: color, } }); line.scrollUV = true; }
这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。
V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。
V2EX is a community of developers, designers and creative people.