|
@@ -12,7 +12,7 @@ var token = window.localStorage.dcj_token
|
|
|
var _musicMaxWeight = 8//M
|
|
|
var cmp = getQueryVariable('cmp') || ''
|
|
|
|
|
|
-
|
|
|
+var _hotNum = 0
|
|
|
|
|
|
function reData(data,type) {
|
|
|
return JSON.stringify(data) == type ? null : data
|
|
@@ -40,7 +40,7 @@ var EditTools = function (n) {
|
|
|
EditTools.prototype.init = function () {
|
|
|
this.hotpoint.init(this.n);
|
|
|
var that = this;
|
|
|
- this.saveAll();
|
|
|
+ this.initSaveAll();
|
|
|
this.active();
|
|
|
//请求数据someData.js
|
|
|
$.ajax(g_Prefix + "data/" + window.number + "/someData.json" + "?" + Date.now(), { dataType: "json" })
|
|
@@ -132,7 +132,7 @@ EditTools.prototype.active = function () {
|
|
|
|
|
|
}
|
|
|
//保存按钮
|
|
|
-EditTools.prototype.saveAll = function () {
|
|
|
+EditTools.prototype.initSaveAll = function () {
|
|
|
var that = this;
|
|
|
|
|
|
$('#save').on('click', function () {
|
|
@@ -143,35 +143,38 @@ EditTools.prototype.saveAll = function () {
|
|
|
})
|
|
|
var hots = {}
|
|
|
// 热点数据
|
|
|
- Array.from($('.spotList ul li')).forEach(function (dom) {
|
|
|
- var sid = dom.hotMesh.belongHot.sid;
|
|
|
- var hot = player.model.hots[sid];
|
|
|
- hots[sid] = {
|
|
|
+ var hotLength = 0;
|
|
|
+
|
|
|
+
|
|
|
+ for(let i in player.model.hots){
|
|
|
+ let hot = player.model.hots[i];
|
|
|
+ hots[i] = {
|
|
|
position: {
|
|
|
- x: dom.hotMesh.position.x,
|
|
|
- y: dom.hotMesh.position.y,
|
|
|
- z: dom.hotMesh.position.z
|
|
|
+ x: hot.mesh.position.x,
|
|
|
+ y: hot.mesh.position.y,
|
|
|
+ z: hot.mesh.position.z
|
|
|
},
|
|
|
//有的定制场景代码是旧的,只能使用rotation,所以不输出quaternion :
|
|
|
- rotation : hot.isSprite ? new THREE.Euler().setFromQuaternion(hot.quaternion).toObject() : dom.hotMesh.rotation.toObject()
|
|
|
+ rotation : hot.isSprite ? new THREE.Euler().setFromQuaternion(hot.quaternion).toObject() : hot.mesh.rotation.toObject()
|
|
|
,
|
|
|
isSprite : hot.isSprite ? 1 : 0,
|
|
|
noAction : hot.noAction ? 1 : 0,
|
|
|
- infoAttribute: dom.infoAttribute
|
|
|
-
|
|
|
+ infoAttribute: hot.infoAttribute ,
|
|
|
+ order : hotLength++ //因为热点保存后在hots里的顺序会被修改,所以使用order来记录顺序
|
|
|
}
|
|
|
if(hot.visiblePanos) hots[sid].visiblePanos = hot.visiblePanos
|
|
|
|
|
|
|
|
|
-
|
|
|
- delete dom.infoAttribute.position;
|
|
|
- delete dom.infoAttribute.quaternion;
|
|
|
- delete dom.infoAttribute.rotation;
|
|
|
-
|
|
|
- })
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
+ if(hot.infoAttribute){
|
|
|
+ delete hot.infoAttribute.position;
|
|
|
+ delete hot.infoAttribute.quaternion;
|
|
|
+ delete hot.infoAttribute.rotation;
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
var info = {
|
|
|
name: $('#pjtName').val(),
|
|
|
summary: $('#info-summary').val(),
|
|
@@ -216,7 +219,7 @@ EditTools.prototype.saveAll = function () {
|
|
|
url: ceshi + url,
|
|
|
data: JSON.stringify({
|
|
|
sceneCode:number,
|
|
|
- hots: reData(hots,'{}') ,
|
|
|
+ hots: reData(hots,'{}') ,
|
|
|
name: number,
|
|
|
guides: reData(guides,'[]'),
|
|
|
info: info,
|
|
@@ -437,7 +440,7 @@ Hotpoint.prototype.init = function (n) {
|
|
|
this.addMusic(); // 添加音乐
|
|
|
this.addModel(); // 添加模型
|
|
|
this.addwebPack(); // 添加外链
|
|
|
- this.saveHot(); // 保存热点
|
|
|
+ this.initSaveHot(); // 保存热点
|
|
|
var that = this;
|
|
|
let hotIconScale = $('#hotIconScale');
|
|
|
|
|
@@ -457,7 +460,7 @@ Hotpoint.prototype.init = function (n) {
|
|
|
} else {
|
|
|
if (target.hasClass("DelConfirm")) {
|
|
|
e.stopPropagation();
|
|
|
- that.remHot(target, n);
|
|
|
+ that.removeHot(target, n);
|
|
|
} else {
|
|
|
//点击热点列表弹出编辑热点窗口
|
|
|
if (target.hasClass("title") || target.hasClass("icon")) {
|
|
@@ -470,10 +473,10 @@ Hotpoint.prototype.init = function (n) {
|
|
|
//点击热点编辑窗口右上角的关闭按钮
|
|
|
this.hotpointDetail.find("a.close, button.cancel").on("click", function () {
|
|
|
var spot_id = that.hotpointDetail.attr("data-id");
|
|
|
+ var hot = player.model.hots[spot_id];
|
|
|
|
|
|
- var info = that.hotpointDetail[0].targetDOM.infoAttribute;
|
|
|
- if(info){
|
|
|
- var hot = player.model.hots[spot_id];
|
|
|
+ var info = hot.infoAttribute; //that.hotpointDetail[0].targetDOM.infoAttribute;
|
|
|
+ if(info){
|
|
|
info.position && hot.mesh.position.copy(info.position)
|
|
|
info.quaternion && hot.mesh.quaternion.copy(info.quaternion)
|
|
|
hot.isSprite = info.isSprite
|
|
@@ -483,13 +486,15 @@ Hotpoint.prototype.init = function (n) {
|
|
|
transformControls.detach()
|
|
|
});
|
|
|
|
|
|
- //遍历热点 初始话加载热点数据
|
|
|
- for (var i = 0; i < g_HotMeshes.length; i++) {
|
|
|
- this.spotList.children("ul").append(this.addHotList(g_HotMeshes[i], i));
|
|
|
+
|
|
|
+ //创建列表
|
|
|
+ for(let i in player.model.hots){
|
|
|
+ this.addHotList(player.model.hots[i]);
|
|
|
}
|
|
|
- this.spotList.find("i").text(g_HotMeshes.length);
|
|
|
- // 初始话的时候把热点信息添加到对应的热点中
|
|
|
- $.ajax(g_Prefix + "data/" + window.number + "/hot/js/data.js" + "?" + Date.now(), { dataType: "json" })
|
|
|
+
|
|
|
+
|
|
|
+ // 初始话的时候把热点信息添加到对应的热点中 直接使用data2.json的会怎样?
|
|
|
+ /* $.ajax(g_Prefix + "data/" + window.number + "/hot/js/data.js" + "?" + Date.now(), { dataType: "json" })
|
|
|
.then(function (infos) {
|
|
|
that.infos = infos ;
|
|
|
Object.keys(infos).forEach(function (key) {
|
|
@@ -498,7 +503,7 @@ Hotpoint.prototype.init = function (n) {
|
|
|
that.spotList.find("ul li[data-spid=" + key + "]")[0] && (that.spotList.find("ul li[data-spid=" + key + "]")[0].infoAttribute = infos[key])&& (that.spotList.find("ul li[data-spid=" + key + "] .title").html(infos[key].title));
|
|
|
|
|
|
})
|
|
|
- })
|
|
|
+ }) */
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -513,13 +518,13 @@ Hotpoint.prototype.editHot = function (target) {
|
|
|
$layout.targetDOM = target.closest("li")[0];//closest匹配选择器的第一个祖先元素
|
|
|
//编辑时将热点列表唯一标识带入,以便后期保存使用识别
|
|
|
var li_id = $($layout.targetDOM).attr("data-spid");
|
|
|
-
|
|
|
+ this.editSpot = player.model.hots[li_id];
|
|
|
|
|
|
this.hotpointDetail.attr("data-id",li_id);
|
|
|
- var info = $layout.targetDOM.infoAttribute || {}
|
|
|
+ var info = this.editSpot.infoAttribute || {} //$layout.targetDOM.infoAttribute || {}
|
|
|
transformControls.transCtlChangeMode("translate")
|
|
|
|
|
|
- this.editSpot = player.model.hots[li_id];
|
|
|
+
|
|
|
|
|
|
|
|
|
// 参数初始化
|
|
@@ -584,7 +589,8 @@ Hotpoint.prototype.editHot = function (target) {
|
|
|
this.hotpointDetail.find("#upload-hotBgm").removeAttr('data-hotBgm') // 没有背景音乐,则移除该属性, 避免其他热点的干扰
|
|
|
}
|
|
|
|
|
|
- $layout.targetDOM.infoAttribute = info
|
|
|
+ // $layout.targetDOM.infoAttribute = info
|
|
|
+ this.editSpot.infoAttribute = info
|
|
|
|
|
|
}
|
|
|
//添加图片和视频
|
|
@@ -785,26 +791,26 @@ Hotpoint.prototype.active = function () {
|
|
|
Hotpoint.prototype.state = function (that, Hot) {
|
|
|
if (g_HotStatus === "add") {
|
|
|
//console.log(Hot)
|
|
|
- this.addHot(that, Hot, function () {
|
|
|
- this.addHotList(g_HotMeshes, g_HotMeshes.length - 1);
|
|
|
- this.spotList.find("i").text(this.spotList.find("ul li").length);
|
|
|
+ this.addHot(that, Hot, (hot)=> {
|
|
|
+ this.addHotList(hot);
|
|
|
});
|
|
|
}
|
|
|
}
|
|
|
+Hotpoint.prototype.updateNumDisplay = function(){
|
|
|
+ this.spotList.find("i").text(this.spotList.find("ul li").length);
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
//删除热点
|
|
|
-Hotpoint.prototype.remHot = function (that, thisScene) {
|
|
|
+Hotpoint.prototype.removeHot = function (that, thisScene) {
|
|
|
var hotId = that.closest("li").attr("data-spid");
|
|
|
- for (var i = 0; i < g_HotMeshes.length; i++) {
|
|
|
- if (g_HotMeshes[i].belongHot.sid === hotId) {
|
|
|
- //在场景中删除这个热点模型
|
|
|
- thisScene.scene.remove(g_HotMeshes[i]);
|
|
|
- g_HotMeshes[i].visible = false;
|
|
|
- //如果热点数据中有这个热点数据就删除
|
|
|
- //g_HotMeshes.splice(i, 1);
|
|
|
- }
|
|
|
- }
|
|
|
+
|
|
|
+ player.model.hots[hotId].dispose();
|
|
|
+ delete player.model.hots[hotId]
|
|
|
+
|
|
|
that.closest("li").remove();
|
|
|
- this.spotList.find(".hotNum").text(this.spotList.find("ul li").length);
|
|
|
+ this.updateNumDisplay()
|
|
|
console.log("删除成功:" + hotId);
|
|
|
}
|
|
|
//添加热点模型
|
|
@@ -824,6 +830,8 @@ Hotpoint.prototype.addHot = function (that, Hot, fn) {
|
|
|
hot.mesh.lookAt(window.hotIntersect.face.normal.clone().add(hotIntersect.point));
|
|
|
hot.mesh.position.add(window.hotIntersect.face.normal.clone().multiplyScalar(0.01))
|
|
|
}
|
|
|
+ hot.quaternion.copy(hot.mesh.quaternion)
|
|
|
+ hot.position.copy(hot.mesh.position)
|
|
|
|
|
|
g_HotStatus = false;
|
|
|
that.mouseCouldBeClickToMove = false;
|
|
@@ -831,29 +839,30 @@ Hotpoint.prototype.addHot = function (that, Hot, fn) {
|
|
|
//添加完热点之后的回调函数
|
|
|
if (g_HotMeshes && g_newHot.length === g_newHot.length++) {
|
|
|
var thisScene = that;
|
|
|
- fn && fn.call(this, thisScene);
|
|
|
+ //fn && fn.call(this, thisScene);
|
|
|
+ fn && fn(hot)
|
|
|
}
|
|
|
}
|
|
|
-//创建热点列表的dom
|
|
|
-Hotpoint.prototype.createDom = function (data, index) {
|
|
|
- var _index = +index + 1;
|
|
|
- return "<li data-spid=" + data.name + " id=ggg_s" + index + ">" +
|
|
|
+
|
|
|
+//添加热点列表
|
|
|
+Hotpoint.prototype.addHotList = function (hot ) {
|
|
|
+
|
|
|
+ var li = $("<li data-spid=" + hot.sid + ">" +
|
|
|
"<div class=icon></div>" +
|
|
|
- "<div class=number title=热点>" + _index + "</div>" +
|
|
|
- "<div class=title title=热点></div>" +
|
|
|
+ "<div class=number title=热点>" + (++_hotNum) + "</div>" +
|
|
|
+ "<div class=title title=热点>" + (hot.infoAttribute && hot.infoAttribute.title || "") + "</div>" +
|
|
|
"<div class=DelConfirm>确定删除</div>" +
|
|
|
"<div class=del></div>" +
|
|
|
- "</li>";
|
|
|
-}
|
|
|
-//添加热点列表
|
|
|
-Hotpoint.prototype.addHotList = function (data, index) {
|
|
|
- if (!data) return;
|
|
|
- this.spotList.children("ul").append(this.createDom(data, index));
|
|
|
- //保存热点信息到热点dom元素中
|
|
|
- var spotList = $(".spotList ul").children("#ggg_s" + index);
|
|
|
- spotList[0].hotMesh = g_HotMeshes[index];
|
|
|
- spotList.attr('data-spid', g_HotMeshes[index].belongHot.sid);
|
|
|
+ "</li>") ;
|
|
|
+
|
|
|
+ li.hot = hot
|
|
|
+ $(".spotList ul").append(li);
|
|
|
+ this.updateNumDisplay()
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
//添加热点音乐
|
|
|
Hotpoint.prototype.addMusic = function () {
|
|
|
var mediaUpload = $("#hotpointDetail .audio.mediaUpload");
|
|
@@ -901,7 +910,7 @@ Hotpoint.prototype.addwebPack = function () {
|
|
|
});
|
|
|
}
|
|
|
// 保存热点信息
|
|
|
-Hotpoint.prototype.saveHot = function () {
|
|
|
+Hotpoint.prototype.initSaveHot = function () {
|
|
|
var $layout = $(".edit-loading");
|
|
|
var hotpointDetail = this.hotpointDetail;
|
|
|
var spotList = this.spotList ;
|
|
@@ -1055,7 +1064,8 @@ Hotpoint.prototype.saveHot = function () {
|
|
|
}).then(function (args) {
|
|
|
console.log(args);
|
|
|
//把获取的所有信息都保存在对应热点的dom元素里面
|
|
|
- hotpointDetail[0].targetDOM.infoAttribute = args;
|
|
|
+ //hotpointDetail[0].targetDOM.infoAttribute = args;
|
|
|
+ hot.infoAttribute = args;
|
|
|
$layout.addClass('hide');
|
|
|
hotpointDetail.addClass("atRight");
|
|
|
spot.find(".title").html(args.title);
|