当前位置:网站首页>Thing JS notes
Thing JS notes
2022-07-23 10:53:00 【Ordinary people 001】
1. Create a scene
// load ThingJS Sample Park
var app = new THING.App({
// Scene address
url: 'https://www.thingjs.com/static/models/factory', // Scene address
// The background color
background: '#000000',
//
env: 'Seaside',
// The sky box
skybox: 'BlueSky',
});2. Loading the map
var app = new THING.App(); // 3D Scene initialization
app.background = [0, 0, 0]; // Set the background of the scene to black
// Reference map component script
THING.Utils.dynamicLoad(['https://www.thingjs.com/uearth/uearth.min.js'], function () {
app.create({
type: 'Map',
// Loaded map path
url: '',
// Initialize the completed function callback
complete: function (event) {
console.log(event.object.userLayers.length);// The log window shows the number of map levels
}
});
});3. Create and destroy objects
var app = new THING.App({
skyBox: "BlueSky",
}); // 3D Scene initialization , Set up sky box
// add to ThingJS Sample Park
var campus1 = app.create({
// The type of object
type: "Campus",
// The path of the object resource
url: "models/factory",
// The position in the world coordinate system , The default location of the system is [0, 0, 0]
position: [0, 0, 0],
id: 11,
name: 'name',
// Callback after object loading
complete: function (ev) {
console.log("Campus created: " + ev.object.id);
}
});
// Add granary Park
var campus2 = app.create({
type: "Campus",
url: "models/silohouse",
position: [50, 0, -150],
complete: function (ev) {
console.log("Campus created: " + ev.object.id);
}
});
// Create multiple objects
// Create button , Click the button to destroy the object
var button = new THING.widget.Button(' Destruction of objects ', function() {
obj.destroy();
});4. adopt load Event loading
app.on('load', function (ev) {
// Get Park objects
var campus = ev.campus;
})5. Query objects by attributes
app.on('load', function () {
new THING.widget.Button(' Press id Inquire about ', queryById);
new THING.widget.Button(' Query by object type ', queryByType);
});
// Search for id by 2271 The object , Click the button to change the color of the object
function queryById() {
var car = app.query('#2271')[0];
car.style.color = '#ff0000';
}
// The query object class is Thing The object of
function queryByType() {
var car = app.query(".Thing");
car.style.color = '#ff0000';
}6. Father son attribute
app.on('load', function (ev) {
// Get Park objects
var campus = ev.campus;
// Access objects through the parent-child tree of the scene
var children = campus.children;
for (var i = 0; i < children.length; i++) {
console.log("children ", children[i])
}
})7. Classification properties
app.on('load', function (ev) {
// Get Park objects
var campus = ev.campus;
// The log window displays the Thing object
campus.things.forEach(function (thing) {
console.log('Thing: ' + thing.id);
});
})边栏推荐
- An analysis of the CPU explosion of an intelligent transportation background service in.Net
- mysql的索引的操作
- Warning lnk4210 reports an error when writing the driver
- 部署storageclass踩坑记录
- Jmeter-记一次自动化造数引发的BeanShell写入excel实例
- 部署metersphere
- 第12届 蓝桥杯 嵌入式设计与开发项目
- A case study on the collaborative management of medical enterprise suppliers, hospitals, patients and other parties by building a low code platform
- [warning] recognizing corrupt image/label during yolov5 training: [errno 2]...... it is impossible to complete the training data set. I will take you to solve it quickly
- 交换机Exchanges
猜你喜欢

300 题 第六讲 二次型

部署storageclass踩坑记录

Deploy metersphere

Recommend a shell installation force artifact, which has been open source! Netizen: really fragrant...

Redis source code and design analysis -- 7. Quick list

Meituan's 8-year experience on how to improve test engineers (automation, performance, test development)

Redis源码与设计剖析 -- 6.压缩列表

Interpretation of ultra fast deep lane detection with hybrid anchor driven ordinal classification

Kubernetes技术与架构(六)
![[unity daily bug] unity reports an unexpected character '‘](/img/e8/11eec670112a5a7e4f1e71dc93c1c0.png)
[unity daily bug] unity reports an unexpected character '‘
随机推荐
MapReduce advanced
Redis源码与设计剖析 -- 5.整数集合
Deploy metersphere
【无标题】
MGRE环境下实现私网互通综合实验
Redis source code and design analysis -- 6. Compressed list
C language n battle -- linked list (IX)
TZC 1283: simple sort - heap sort
Redis source code and design analysis -- 14. Database implementation
Redis source code and design analysis -- 11. Hash object
软件测试基础篇—测试用例的设计方法
Clion + mingw64 configure C language development environment visual studio installation
N wars of C language -- common body and enumeration (VIII)
组件中的自定义事件
Analysis of network security level protection 2.0 standard
C语言n番战--链表(九)
资源池以及资源池化是什么意思?
疫情时期加中年危机——游荡在十字街口的三个月
C语言n番战--结构体(七)
Important knowledge of application layer (interview, reexamination, term end)