@liveroom-tech/react-immersive 4.0.2 → 4.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1 @@
1
+ import"./chunk-JR557W27.mjs";var p=23283064365386963e-26,P=12,g=typeof TextDecoder>"u"?null:new TextDecoder("utf-8"),F=0,l=1,f=2,w=5,c=class{constructor(t=new Uint8Array(16)){this.buf=ArrayBuffer.isView(t)?t:new Uint8Array(t),this.dataView=new DataView(this.buf.buffer),this.pos=0,this.type=0,this.length=this.buf.length}readFields(t,e,r=this.length){for(;this.pos<r;){let s=this.readVarint(),n=s>>3,h=this.pos;this.type=s&7,t(n,e,this),this.pos===h&&this.skip(s)}return e}readMessage(t,e){return this.readFields(t,e,this.readVarint()+this.pos)}readFixed32(){let t=this.dataView.getUint32(this.pos,!0);return this.pos+=4,t}readSFixed32(){let t=this.dataView.getInt32(this.pos,!0);return this.pos+=4,t}readFixed64(){let t=this.dataView.getUint32(this.pos,!0)+this.dataView.getUint32(this.pos+4,!0)*4294967296;return this.pos+=8,t}readSFixed64(){let t=this.dataView.getUint32(this.pos,!0)+this.dataView.getInt32(this.pos+4,!0)*4294967296;return this.pos+=8,t}readFloat(){let t=this.dataView.getFloat32(this.pos,!0);return this.pos+=4,t}readDouble(){let t=this.dataView.getFloat64(this.pos,!0);return this.pos+=8,t}readVarint(t){let e=this.buf,r,s;return s=e[this.pos++],r=s&127,s<128||(s=e[this.pos++],r|=(s&127)<<7,s<128)||(s=e[this.pos++],r|=(s&127)<<14,s<128)||(s=e[this.pos++],r|=(s&127)<<21,s<128)?r:(s=e[this.pos],r|=(s&15)<<28,k(r,t,this))}readVarint64(){return this.readVarint(!0)}readSVarint(){let t=this.readVarint();return t%2===1?(t+1)/-2:t/2}readBoolean(){return!!this.readVarint()}readString(){let t=this.readVarint()+this.pos,e=this.pos;return this.pos=t,t-e>=P&&g?g.decode(this.buf.subarray(e,t)):U(this.buf,e,t)}readBytes(){let t=this.readVarint()+this.pos,e=this.buf.subarray(this.pos,t);return this.pos=t,e}readPackedVarint(t=[],e){let r=this.readPackedEnd();for(;this.pos<r;)t.push(this.readVarint(e));return t}readPackedSVarint(t=[]){let e=this.readPackedEnd();for(;this.pos<e;)t.push(this.readSVarint());return t}readPackedBoolean(t=[]){let e=this.readPackedEnd();for(;this.pos<e;)t.push(this.readBoolean());return t}readPackedFloat(t=[]){let e=this.readPackedEnd();for(;this.pos<e;)t.push(this.readFloat());return t}readPackedDouble(t=[]){let e=this.readPackedEnd();for(;this.pos<e;)t.push(this.readDouble());return t}readPackedFixed32(t=[]){let e=this.readPackedEnd();for(;this.pos<e;)t.push(this.readFixed32());return t}readPackedSFixed32(t=[]){let e=this.readPackedEnd();for(;this.pos<e;)t.push(this.readSFixed32());return t}readPackedFixed64(t=[]){let e=this.readPackedEnd();for(;this.pos<e;)t.push(this.readFixed64());return t}readPackedSFixed64(t=[]){let e=this.readPackedEnd();for(;this.pos<e;)t.push(this.readSFixed64());return t}readPackedEnd(){return this.type===f?this.readVarint()+this.pos:this.pos+1}skip(t){let e=t&7;if(e===F)for(;this.buf[this.pos++]>127;);else if(e===f)this.pos=this.readVarint()+this.pos;else if(e===w)this.pos+=4;else if(e===l)this.pos+=8;else throw new Error(`Unimplemented type: ${e}`)}writeTag(t,e){this.writeVarint(t<<3|e)}realloc(t){let e=this.length||16;for(;e<this.pos+t;)e*=2;if(e!==this.length){let r=new Uint8Array(e);r.set(this.buf),this.buf=r,this.dataView=new DataView(r.buffer),this.length=e}}finish(){return this.length=this.pos,this.pos=0,this.buf.subarray(0,this.length)}writeFixed32(t){this.realloc(4),this.dataView.setInt32(this.pos,t,!0),this.pos+=4}writeSFixed32(t){this.realloc(4),this.dataView.setInt32(this.pos,t,!0),this.pos+=4}writeFixed64(t){this.realloc(8),this.dataView.setInt32(this.pos,t&-1,!0),this.dataView.setInt32(this.pos+4,Math.floor(t*p),!0),this.pos+=8}writeSFixed64(t){this.realloc(8),this.dataView.setInt32(this.pos,t&-1,!0),this.dataView.setInt32(this.pos+4,Math.floor(t*p),!0),this.pos+=8}writeVarint(t){if(t=+t||0,t>268435455||t<0){S(t,this);return}this.realloc(4),this.buf[this.pos++]=t&127|(t>127?128:0),!(t<=127)&&(this.buf[this.pos++]=(t>>>=7)&127|(t>127?128:0),!(t<=127)&&(this.buf[this.pos++]=(t>>>=7)&127|(t>127?128:0),!(t<=127)&&(this.buf[this.pos++]=t>>>7&127)))}writeSVarint(t){this.writeVarint(t<0?-t*2-1:t*2)}writeBoolean(t){this.writeVarint(+t)}writeString(t){t=String(t),this.realloc(t.length*4),this.pos++;let e=this.pos;this.pos=L(this.buf,t,this.pos);let r=this.pos-e;r>=128&&V(e,r,this),this.pos=e-1,this.writeVarint(r),this.pos+=r}writeFloat(t){this.realloc(4),this.dataView.setFloat32(this.pos,t,!0),this.pos+=4}writeDouble(t){this.realloc(8),this.dataView.setFloat64(this.pos,t,!0),this.pos+=8}writeBytes(t){let e=t.length;this.writeVarint(e),this.realloc(e);for(let r=0;r<e;r++)this.buf[this.pos++]=t[r]}writeRawMessage(t,e){this.pos++;let r=this.pos;t(e,this);let s=this.pos-r;s>=128&&V(r,s,this),this.pos=r-1,this.writeVarint(s),this.pos+=s}writeMessage(t,e,r){this.writeTag(t,f),this.writeRawMessage(e,r)}writePackedVarint(t,e){e.length&&this.writeMessage(t,B,e)}writePackedSVarint(t,e){e.length&&this.writeMessage(t,T,e)}writePackedBoolean(t,e){e.length&&this.writeMessage(t,M,e)}writePackedFloat(t,e){e.length&&this.writeMessage(t,y,e)}writePackedDouble(t,e){e.length&&this.writeMessage(t,C,e)}writePackedFixed32(t,e){e.length&&this.writeMessage(t,I,e)}writePackedSFixed32(t,e){e.length&&this.writeMessage(t,_,e)}writePackedFixed64(t,e){e.length&&this.writeMessage(t,b,e)}writePackedSFixed64(t,e){e.length&&this.writeMessage(t,m,e)}writeBytesField(t,e){this.writeTag(t,f),this.writeBytes(e)}writeFixed32Field(t,e){this.writeTag(t,w),this.writeFixed32(e)}writeSFixed32Field(t,e){this.writeTag(t,w),this.writeSFixed32(e)}writeFixed64Field(t,e){this.writeTag(t,l),this.writeFixed64(e)}writeSFixed64Field(t,e){this.writeTag(t,l),this.writeSFixed64(e)}writeVarintField(t,e){this.writeTag(t,F),this.writeVarint(e)}writeSVarintField(t,e){this.writeTag(t,F),this.writeSVarint(e)}writeStringField(t,e){this.writeTag(t,f),this.writeString(e)}writeFloatField(t,e){this.writeTag(t,w),this.writeFloat(e)}writeDoubleField(t,e){this.writeTag(t,l),this.writeDouble(e)}writeBooleanField(t,e){this.writeVarintField(t,+e)}};function k(i,t,e){let r=e.buf,s,n;if(n=r[e.pos++],s=(n&112)>>4,n<128||(n=r[e.pos++],s|=(n&127)<<3,n<128)||(n=r[e.pos++],s|=(n&127)<<10,n<128)||(n=r[e.pos++],s|=(n&127)<<17,n<128)||(n=r[e.pos++],s|=(n&127)<<24,n<128)||(n=r[e.pos++],s|=(n&1)<<31,n<128))return x(i,s,t);throw new Error("Expected varint not more than 10 bytes")}function x(i,t,e){return e?t*4294967296+(i>>>0):(t>>>0)*4294967296+(i>>>0)}function S(i,t){let e,r;if(i>=0?(e=i%4294967296|0,r=i/4294967296|0):(e=~(-i%4294967296),r=~(-i/4294967296),e^4294967295?e=e+1|0:(e=0,r=r+1|0)),i>=18446744073709552e3||i<-18446744073709552e3)throw new Error("Given varint doesn't fit into 10 bytes");t.realloc(10),D(e,r,t),E(r,t)}function D(i,t,e){e.buf[e.pos++]=i&127|128,i>>>=7,e.buf[e.pos++]=i&127|128,i>>>=7,e.buf[e.pos++]=i&127|128,i>>>=7,e.buf[e.pos++]=i&127|128,i>>>=7,e.buf[e.pos]=i&127}function E(i,t){let e=(i&7)<<4;t.buf[t.pos++]|=e|((i>>>=3)?128:0),i&&(t.buf[t.pos++]=i&127|((i>>>=7)?128:0),i&&(t.buf[t.pos++]=i&127|((i>>>=7)?128:0),i&&(t.buf[t.pos++]=i&127|((i>>>=7)?128:0),i&&(t.buf[t.pos++]=i&127|((i>>>=7)?128:0),i&&(t.buf[t.pos++]=i&127)))))}function V(i,t,e){let r=t<=16383?1:t<=2097151?2:t<=268435455?3:Math.floor(Math.log(t)/(Math.LN2*7));e.realloc(r);for(let s=e.pos-1;s>=i;s--)e.buf[s+r]=e.buf[s]}function B(i,t){for(let e=0;e<i.length;e++)t.writeVarint(i[e])}function T(i,t){for(let e=0;e<i.length;e++)t.writeSVarint(i[e])}function y(i,t){for(let e=0;e<i.length;e++)t.writeFloat(i[e])}function C(i,t){for(let e=0;e<i.length;e++)t.writeDouble(i[e])}function M(i,t){for(let e=0;e<i.length;e++)t.writeBoolean(i[e])}function I(i,t){for(let e=0;e<i.length;e++)t.writeFixed32(i[e])}function _(i,t){for(let e=0;e<i.length;e++)t.writeSFixed32(i[e])}function b(i,t){for(let e=0;e<i.length;e++)t.writeFixed64(i[e])}function m(i,t){for(let e=0;e<i.length;e++)t.writeSFixed64(i[e])}function U(i,t,e){let r="",s=t;for(;s<e;){let n=i[s],h=null,a=n>239?4:n>223?3:n>191?2:1;if(s+a>e)break;let o,d,u;a===1?n<128&&(h=n):a===2?(o=i[s+1],(o&192)===128&&(h=(n&31)<<6|o&63,h<=127&&(h=null))):a===3?(o=i[s+1],d=i[s+2],(o&192)===128&&(d&192)===128&&(h=(n&15)<<12|(o&63)<<6|d&63,(h<=2047||h>=55296&&h<=57343)&&(h=null))):a===4&&(o=i[s+1],d=i[s+2],u=i[s+3],(o&192)===128&&(d&192)===128&&(u&192)===128&&(h=(n&15)<<18|(o&63)<<12|(d&63)<<6|u&63,(h<=65535||h>=1114112)&&(h=null))),h===null?(h=65533,a=1):h>65535&&(h-=65536,r+=String.fromCharCode(h>>>10&1023|55296),h=56320|h&1023),r+=String.fromCharCode(h),s+=a}return r}function L(i,t,e){for(let r=0,s,n;r<t.length;r++){if(s=t.charCodeAt(r),s>55295&&s<57344)if(n)if(s<56320){i[e++]=239,i[e++]=191,i[e++]=189,n=s;continue}else s=n-55296<<10|s-56320|65536,n=null;else{s>56319||r+1===t.length?(i[e++]=239,i[e++]=191,i[e++]=189):n=s;continue}else n&&(i[e++]=239,i[e++]=191,i[e++]=189,n=null);s<128?i[e++]=s:(s<2048?i[e++]=s>>6|192:(s<65536?i[e++]=s>>12|224:(i[e++]=s>>18|240,i[e++]=s>>12&63|128),i[e++]=s>>6&63|128),i[e++]=s&63|128)}return e}export{c as default};
@@ -0,0 +1 @@
1
+ import"./chunk-JR557W27.mjs";function y(t,e){this.x=t,this.y=e}y.prototype={clone(){return new y(this.x,this.y)},add(t){return this.clone()._add(t)},sub(t){return this.clone()._sub(t)},multByPoint(t){return this.clone()._multByPoint(t)},divByPoint(t){return this.clone()._divByPoint(t)},mult(t){return this.clone()._mult(t)},div(t){return this.clone()._div(t)},rotate(t){return this.clone()._rotate(t)},rotateAround(t,e){return this.clone()._rotateAround(t,e)},matMult(t){return this.clone()._matMult(t)},unit(){return this.clone()._unit()},perp(){return this.clone()._perp()},round(){return this.clone()._round()},mag(){return Math.sqrt(this.x*this.x+this.y*this.y)},equals(t){return this.x===t.x&&this.y===t.y},dist(t){return Math.sqrt(this.distSqr(t))},distSqr(t){let e=t.x-this.x,n=t.y-this.y;return e*e+n*n},angle(){return Math.atan2(this.y,this.x)},angleTo(t){return Math.atan2(this.y-t.y,this.x-t.x)},angleWith(t){return this.angleWithSep(t.x,t.y)},angleWithSep(t,e){return Math.atan2(this.x*e-this.y*t,this.x*t+this.y*e)},_matMult(t){let e=t[0]*this.x+t[1]*this.y,n=t[2]*this.x+t[3]*this.y;return this.x=e,this.y=n,this},_add(t){return this.x+=t.x,this.y+=t.y,this},_sub(t){return this.x-=t.x,this.y-=t.y,this},_mult(t){return this.x*=t,this.y*=t,this},_div(t){return this.x/=t,this.y/=t,this},_multByPoint(t){return this.x*=t.x,this.y*=t.y,this},_divByPoint(t){return this.x/=t.x,this.y/=t.y,this},_unit(){return this._div(this.mag()),this},_perp(){let t=this.y;return this.y=this.x,this.x=-t,this},_rotate(t){let e=Math.cos(t),n=Math.sin(t),i=e*this.x-n*this.y,s=n*this.x+e*this.y;return this.x=i,this.y=s,this},_rotateAround(t,e){let n=Math.cos(t),i=Math.sin(t),s=e.x+n*(this.x-e.x)-i*(this.y-e.y),r=e.y+i*(this.x-e.x)+n*(this.y-e.y);return this.x=s,this.y=r,this},_round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this},constructor:y};y.convert=function(t){if(t instanceof y)return t;if(Array.isArray(t))return new y(+t[0],+t[1]);if(t.x!==void 0&&t.y!==void 0)return new y(+t.x,+t.y);throw new Error("Expected [x, y] or {x, y} point format")};var f=class{constructor(e,n,i,s,r){for(this.properties=Object.create(null),this.extent=i,this.type=0,this.id=void 0,this._pbf=e,this._geometry=-1,this._keys=s,this._values=r;e.pos<n;){let o=e.readVarint();if(o===8)this.id=e.readVarint();else if(o===18){let h=e.readVarint()+e.pos;for(;e.pos<h;){let u=s[e.readVarint()],l=r[e.readVarint()];this.properties[u]=l}}else o===24?this.type=e.readVarint():(o===34&&(this._geometry=e.pos),e.skip(o))}}loadGeometry(){if(this._geometry<0)throw new Error("feature has no geometry");let e=this._pbf;e.pos=this._geometry;let n=e.readVarint()+e.pos,i=[],s,r=1,o=0,h=0,u=0;for(;e.pos<n;){if(o<=0){let l=e.readVarint();if(r=l&7,o=l>>3,o===0)continue}if(o--,r===1)h+=e.readSVarint(),u+=e.readSVarint(),s&&i.push(s),s=[new y(h,u)];else if(r===2)h+=e.readSVarint(),u+=e.readSVarint(),s&&s.push(new y(h,u));else if(r===7)s&&s.push(s[0].clone());else throw new Error(`unknown command ${r}`)}return s&&i.push(s),i}bbox(){if(this._geometry<0)throw new Error("feature has no geometry");let e=this._pbf;e.pos=this._geometry;let n=e.readVarint()+e.pos,i=1,s=0,r=0,o=0,h=1/0,u=-1/0,l=1/0,d=-1/0;for(;e.pos<n;){if(s<=0){let x=e.readVarint();if(i=x&7,s=x>>3,s===0)continue}if(s--,i===1||i===2)r+=e.readSVarint(),o+=e.readSVarint(),r<h&&(h=r),r>u&&(u=r),o<l&&(l=o),o>d&&(d=o);else if(i!==7)throw new Error(`unknown command ${i}`)}return[h,l,u,d]}toGeoJSON(e,n,i){let s=this.extent*Math.pow(2,i),r=this.extent*e,o=this.extent*n,h=this.loadGeometry();function u(a){return[(a.x+r)*360/s-180,360/Math.PI*Math.atan(Math.exp((1-(a.y+o)*2/s)*Math.PI))-90]}function l(a){return a.map(u)}let d;if(this.type===1){let a=[];for(let _ of h)a.push(_[0]);let c=l(a);d=a.length===1?{type:"Point",coordinates:c[0]}:{type:"MultiPoint",coordinates:c}}else if(this.type===2){let a=h.map(l);d=a.length===1?{type:"LineString",coordinates:a[0]}:{type:"MultiLineString",coordinates:a}}else if(this.type===3){let a=m(h),c=[];for(let _ of a)c.push(_.map(l));d=c.length===1?{type:"Polygon",coordinates:c[0]}:{type:"MultiPolygon",coordinates:c}}else throw new Error("unknown feature type");let x={type:"Feature",geometry:d,properties:this.properties};return this.id!=null&&(x.id=this.id),x}};f.types=["Unknown","Point","LineString","Polygon"];function m(t){let e=t.length;if(e<=1)return[t];let n=[],i,s;for(let r=0;r<e;r++){let o=w(t[r]);o!==0&&(s===void 0&&(s=o<0),s===o<0?(i&&n.push(i),i=[t[r]]):i&&i.push(t[r]))}return i&&n.push(i),n}function w(t){let e=0;for(let n=0,i=t.length,s=i-1,r,o;n<i;s=n++)r=t[n],o=t[s],e+=(o.x-r.x)*(r.y+o.y);return e}var g=class{constructor(e,n){for(this.version=1,this.name="",this.extent=4096,this.length=0,this._pbf=e,this._keys=[],this._values=[],this._features=[],n===void 0&&(n=e.length);e.pos<n;){let i=e.readVarint();i===10?this.name=e.readString():i===18?(this._features.push(e.pos),e.skip(i)):i===26?this._keys.push(e.readString()):i===34?this._values.push(V(e)):i===40?this.extent=e.readVarint():i===120?this.version=e.readVarint():e.skip(i)}this.length=this._features.length}feature(e){if(e<0||e>=this._features.length)throw new Error("feature index out of bounds");this._pbf.pos=this._features[e];let n=this._pbf.readVarint()+this._pbf.pos;return new f(this._pbf,n,this.extent,this._keys,this._values)}};function V(t){let e=null,n=t.readVarint()+t.pos;for(;t.pos<n;){let i=t.readVarint();e=i===10?t.readString():i===21?t.readFloat():i===25?t.readDouble():i===32?t.readVarint64():i===40?t.readVarint():i===48?t.readSVarint():i===56?t.readBoolean():(t.skip(i),null)}if(e==null)throw new Error("unknown feature value");return e}var p=class{constructor(e,n=e.length){let i=Object.create(null);for(;e.pos<n;){let s=e.readVarint();if(s===26){let r=new g(e,e.readVarint()+e.pos);r.length&&(i[r.name]=r)}else e.skip(s)}this.layers=i}};export{p as VectorTile,f as VectorTileFeature,g as VectorTileLayer,m as classifyRings};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@liveroom-tech/react-immersive",
3
- "version": "4.0.2",
3
+ "version": "4.1.0",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/index.mjs",
6
6
  "types": "dist/index.d.ts",
@@ -34,7 +34,8 @@
34
34
  "publish:minor": "npm version minor && npm run build && npm publish",
35
35
  "publish:major": "npm version major && npm run build && npm publish",
36
36
  "prebuild": "node scripts/build-bvh-worker.mjs",
37
- "predev": "node scripts/build-bvh-worker.mjs"
37
+ "predev": "node scripts/build-bvh-worker.mjs",
38
+ "test": "tsx --test \"src/**/*.test.ts\""
38
39
  },
39
40
  "peerDependencies": {
40
41
  "@react-three/drei": "^10.7.7",
@@ -60,6 +61,7 @@
60
61
  "@react-three/fiber": "^9.6.1",
61
62
  "@react-three/postprocessing": "^3.0.4",
62
63
  "@react-three/xr": "^6.6.30",
64
+ "@types/node": "^26.4.1",
63
65
  "@types/react": "^18.0.0",
64
66
  "@types/three": "^0.184.1",
65
67
  "@vitejs/plugin-react": "^6.0.2",
@@ -70,6 +72,7 @@
70
72
  "three": "^0.184.0",
71
73
  "three-stdlib": "^2.36.0",
72
74
  "tsup": "^8.0.0",
75
+ "tsx": "^4.23.13",
73
76
  "typescript": "^5.0.0",
74
77
  "vite": "^8.0.14"
75
78
  },