From 5431efa2c5f83b3fd7127dbb6f7b2b546a07cb27 Mon Sep 17 00:00:00 2001 From: zh <972939975@qq.com> Date: Fri, 4 Jul 2025 13:57:08 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=A0=87=E6=B3=A8=E5=9B=BE?= =?UTF-8?q?=E7=89=87=E5=9C=B0=E5=9D=80404=E5=88=A4=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Obj/Base/BillboardObject/index.js | 68 ++++++++++++++++++++++++--- static/3rdparty/libgif.js | 8 +++- static/custom/css/index.css | 4 ++ 3 files changed, 73 insertions(+), 7 deletions(-) diff --git a/src/Obj/Base/BillboardObject/index.js b/src/Obj/Base/BillboardObject/index.js index 78c009d..c836256 100644 --- a/src/Obj/Base/BillboardObject/index.js +++ b/src/Obj/Base/BillboardObject/index.js @@ -231,7 +231,20 @@ class BillboardObject extends Base { that._superGif = superGif that._superGif.id = id // 自定义id,用于判断gif实例是否改变 - superGif.load(function () { + superGif.load(function (status) { + if (status == 404) { + canvas = document.createElement('canvas') + canvas.width = 0 + canvas.height = 0 + billboardH = 0 + if (that.entity) { + that.entity.billboard.imgWidth = 0 + that.entity.billboard.imgHeight = 0 + that.entity.billboard.image = canvas + addCluster(that.sdk, that.entity) + } + return + } if (that._superGif.id != id) { return } @@ -286,6 +299,17 @@ class BillboardObject extends Base { addCluster(that.sdk, that.entity) } } + image.onerror = function (err) { + canvas.width = 0 + canvas.height = 0 + billboardH = 0 + if (that.entity) { + that.entity.billboard.imgWidth = 0 + that.entity.billboard.imgHeight = 0 + that.entity.billboard.image = canvas + addCluster(that.sdk, that.entity) + } + }; } that.entity = new Cesium.Entity({ @@ -729,7 +753,24 @@ class BillboardObject extends Base { let billboardH = 36 let index = 0 _this._frameImages = [] - superGif.load(function () { + superGif.load(function (status) { + if (status == 404) { + canvas = document.createElement('canvas') + canvas.width = 0 + canvas.height = 0 + billboardH = 0 + _this.entity.billboard.imgWidth = 0 + _this.entity.billboard.imgHeight = 0 + _this.entity && (_this.entity.billboard.image = canvas) + _this.entity.billboard.height = new Cesium.CallbackProperty(function () { + return 0 + }, false) + _this.entity.label.pixelOffset = new Cesium.CallbackProperty(function () { + return new Cesium.Cartesian2(0, 0) + }, false) + billboardH = height * (31 / width) + return + } if (_this._superGif.id != id) { return } @@ -802,6 +843,21 @@ class BillboardObject extends Base { }, false) billboardH = height * (31 / width) } + image.onerror = function (err) { + canvas.width = 0 + canvas.height = 0 + billboardH = 0 + _this.entity.billboard.imgWidth = 0 + _this.entity.billboard.imgHeight = 0 + _this.entity && (_this.entity.billboard.image = canvas) + _this.entity.billboard.height = new Cesium.CallbackProperty(function () { + return 0 + }, false) + _this.entity.label.pixelOffset = new Cesium.CallbackProperty(function () { + return new Cesium.Cartesian2(0, 0) + }, false) + billboardH = height * (31 / width) + }; } } @@ -2077,9 +2133,9 @@ class BillboardObject extends Base { // ) this.entity.label.pixelOffset = new Cesium.CallbackProperty(function () { if (_this.options.billboard.show) { - let billboardH = + let billboardH = _this.entity.billboard.imgHeight ? _this.entity.billboard.imgHeight * - (31 / _this.entity.billboard.imgWidth) + (31 / _this.entity.billboard.imgWidth) : 0 return new Cesium.Cartesian2( 0, -billboardH * _this.options.billboard.scale - @@ -2224,7 +2280,7 @@ class BillboardObject extends Base { .value ) { this.options.attribute.vr.content.push({ - name: '全景图' , + name: '全景图', url: this._DialogObject._element.content.getElementsByClassName( 'vr_add' )[0].value @@ -2240,7 +2296,7 @@ class BillboardObject extends Base { addAttributeRr(vr) { this.options.attribute.vr.content.push({ - name: '全景图' , + name: '全景图', url: vr }) this.attributeVr = this.options.attribute.vr.content diff --git a/static/3rdparty/libgif.js b/static/3rdparty/libgif.js index 6d0b586..ce5a948 100644 --- a/static/3rdparty/libgif.js +++ b/static/3rdparty/libgif.js @@ -926,8 +926,14 @@ get_current_frame: function() { return player.current_frame() }, load_url: function(src,callback){ if (!load_setup(callback)) return; - var h = new XMLHttpRequest(); + h.onreadystatechange = function() { + if (h.readyState == 4) { + if (h.status == 404) { + callback(404) + } + } + }; // new browsers (XMLHttpRequest2-compliant) h.open('GET', src, true); diff --git a/static/custom/css/index.css b/static/custom/css/index.css index cb003ee..904f430 100644 --- a/static/custom/css/index.css +++ b/static/custom/css/index.css @@ -1599,6 +1599,10 @@ width: 23px; height: 26px; cursor: pointer; + border: 1px solid rgba(var(--color-sdk-base-rgb), 0.2); + display: flex; + align-items: center; + justify-content: center; } .YJ-custom-base-dialog.billboard-object>.content div .image {