I can't walk around the scene in VR with Aframe - three.js

I am new with aframe. I don't know if it's a problem or if aframe works like this by default.
When I try to walk in the VR with my mobile phone it doesn't work, but if I walk using AR it works.
Could you tell me if aframe works like this or is it something I'm doing wrong.
Thank you so much.
This is my code
import React from 'react';
import './styles/VirtualReality.css';
import scene from '../assets/scenes/scenario.gltf';
export default function VirtualReality() {
return (
<React.Fragment>
<a-scene vr-mode-ui="enabled: true; cardboardModeEnabled: true;">
<a-asset>
<a-asset-item
id="data"
src='[{"x": 1, "y": 8, "z": 0, "size": 1, "color": "#ff0000"},
{"x": -2, "y": 3, "z": 1, "size": 1.5, "color": "#00ff00"},
{"x": -1, "y": 3, "z": 2, "size": 1, "color": "#0000ff"},
{"x": 2, "y": 7, "z": 7, "size": 1.5, "color": "#0000ff"},
{"x": 1, "y": 6, "z": 3, "size": 1, "color": "#4CC3D9"}]'
></a-asset-item>
</a-asset>
<a-sky gltf-model={scene} color="#ECECEC"></a-sky>
<a-entity
charts="type: bar; dataPoints: #data; axis_length: 12; axis_negative: false; axis_grid: true"
scale="0.15 0.15 0.15"
position="-6 1 -10"
></a-entity>
</a-scene>
</React.Fragment>
);
}
I am using react. And in the scene I am using the default camera.
I tried to walk in VR using aframe, but it didn't work, it just stays in a fixed position, although I can look around. I thought in VR you could walk around just like you do in AR mode.

Related

increase by 50 all numbers of lines with "y" coordinate

I need help. The problem: how to change all specific coordinate values by any number. Like multiplying all values of Y coordinates here by 3 or decreasing all X values by 55.
There is notepad file format with many many lines in it. Tbh thats a hideout file from path of exile game. I want to edit some objects there, so i need to manage coordinate values somehow. The reason why i want it - to share with PoE community some hideout files, but i need to move objects in it to make everything looking good.
I am have no clue how to solve it. I hope to find some wise person here <3
Example:
"Arched Gateway": {
"hash": 3294752266,
"x": 309,
"y": 237,
"r": 1756,
"fv": 0
},
"Arched Gateway": {
"hash": 3294752266,
"x": 305,
"y": 259,
"r": 4586,
"fv": 0
},
"Arched Gateway": {
"hash": 3294752266,
"x": 261,
"y": 302,
"r": 11101,
"fv": 0
},
I want to find out the wat to solve it not manually. Like function in any app or site which can change only Y coordinate values.
You can write a JSONata expression to transform your data, see https://try.jsonata.org/.
But first, you need to fix your data as it's not a valid JSON, because of duplicate key 'Arched Gateway'.
If you modify your input like this for example:
{
"ArchedGateways": [{
"hash": 3294752266,
"x": 309,
"y": 237,
"r": 1756,
"fv": 0
},
{
"hash": 3294752266,
"x": 305,
"y": 259,
"r": 4586,
"fv": 0
},
{
"hash": 3294752266,
"x": 261,
"y": 302,
"r": 11101,
"fv": 0
}
]
}
this JSONata expression would do:
ArchedGateways.{
'hash': hash,
'x': x - 55,
'y': y * 3,
'r': r,
'fv': fv
}

How to do multiple rotations without losing a degree of freedom?

I'm trying to display multiple "3d lines" imported from an XML file. I simply need to draw simple rectangular boxes using the provided parameters (5 x 5 x "length"), move it at the right position and rotate it using the provided rotations (in degree) - the expected result is multiple shapes starting at the provided position with their length continuing in an orientation that match the provided rotation.
For some shapes, two of the rotation axes are doing the exact same thing - this appear to be a gimbal lock issue (probably amplified because most of the rotations here are at 90 degrees).
I searched and tried multiple solutions for hours, notably using a 4x4 matrix instead of my initial implementation using geometry.rotateX/rotateY/rotateZ. Unfortunately, I'm unable to find a working solution... I found people mentioning quaternions, but I'm not quite sure how to apply this to my current use case...
I'm sure there is a (relatively) easy solution for my issue, but right now, I'm unable to find it... I'm open to any way of doing it, as long as it can be done with the input I have...
Can anyone push me in the right direction?
Thank you so much for your help.
For reference, I'm currently using r124. Here's a simplified example of my parsed input :
var lines = [
{
"length": "150",
"position": {
"x": "100",
"y": "-10",
"z": "1800"
},
"rotation": {
"x": "90",
"y": "0",
"z": "0"
}
},
{
"length": "325",
"position": {
"x": "100",
"y": "-10",
"z": "1800"
},
"rotation": {
"x": "-90",
"y": "-90",
"z": "-90"
}
},
{
"length": "55",
"position": {
"x": "100",
"y": "-10",
"z": "1800"
},
"rotation": {
"x": "0",
"y": "0",
"z": "-90"
}
}
]

Convert Flash Coordinate into GeoJSON

I have a legacy .swf file that my team used to create a custom map.
The .swf file looks like this with following format:
{
"Signature": "CWS",
"Version": 8,
"FileLength": 87736,
"FrameSize": {
"Xmin": 0,
"Xmax": 14400,
"Ymin": 0,
"Ymax": 10000
},
"FrameRate": 12,
"FrameCount": 1,
"Tags": [
{
"TagName": "FileAttributes",
"Length": 4,
"Reserved": 0,
"HasMetaData": 0,
"SWFFlagsAS3": 0,
"SWFFlagsNoCrossDomainCache": 0,
"SWFFlagsUseNetwork": 0,
"UNDEFINED": 0
},
{
"TagName": "SetBackgroundColor",
"Length": 3,
"BackgroundColor": [
51,
51,
51
]
},
{
"TagName": "Protect",
"Length": 0
},
{
"TagName": "DefineShape4",
"Length": 309,
"ShapeId": 1,
"ShapeBounds": {
"Xmin": 10629,
"Xmax": 12137,
"Ymin": 4084,
"Ymax": 4748
},
"EdgeBounds": {
"Xmin": 10630,
"Xmax": 12136,
"Ymin": 4085,
"Ymax": 4747
},
"Reserved": 0,
"UsesFillWindingRule": 0,
"UsesNonScalingStrokes": 0,
"UsesScalingStrokes": 1,
"Shapes": {
"FillStyles": [
{
"FillStyleType": 0,
"FillStyleName": "solid fill",
"Color": [
255,
255,
102,
255
]
}
],
"LineStyles": [
{
"Width": 2,
"StartCapStyle": 0,
"JoinStyle": 0,
"HasFillFlag": 0,
"NoHScaleFlag": 0,
"NoVScaleFlag": 0,
"PixelHintingFlag": 0,
"Reserved": 0,
"NoClose": 0,
"EndCapStyle": 0,
"Color": [
255,
255,
255,
255
]
},
{
"Width": 2,
"StartCapStyle": 0,
"JoinStyle": 0,
"HasFillFlag": 0,
"NoHScaleFlag": 0,
"NoVScaleFlag": 0,
"PixelHintingFlag": 0,
"Reserved": 0,
"NoClose": 0,
"EndCapStyle": 0,
"Color": [
255,
255,
102,
255
]
}
],
"FillBits": 1,
"LineBits": 2,
"ShapeRecords": [
{
"RecordType": "stylechange",
"MoveDeltaX": 10630,
"MoveDeltaY": 4306,
"LineStyle": 1
},
{
"RecordType": "straightedge",
"LineType": "General",
"DeltaX": 23,
"DeltaY": -1
},
},
}
What format is this? and is there a way to convert this to GeoJson format so I can use it with d3.js?
To be specific, this is the data data for US combatant command(COCOM) map. I could not find the GeoJson format of this map in the entire Internet, so my only hope is to covert the legacy data into GeoJson
I ended up drawing my own cocom map using Geojson.io. I don't think there is a simple way to convert ShapeRecord to GeoJson since it is a completely different coordinate system.

Algorithm to regroup geographic points

I'm creating an app using a map and I have to place points on it. The problem is that when the points are nearby, the user can't see the difference. So, I need to regroup the points.
I receive JSONs like that:
[{"id": "1", "x": 253, "y": 144},
{"id": "2", "x": 142, "y": 355},
{"id": "3", "x": 175, "y": 330},
{"id": "4", "x": 140, "y": 5},
{"id": "5", "x": 307, "y": 306},
{"id": "6", "x": 233, "y": 304},
{"id": "7", "x": 212, "y": 163},
{"id": "8", "x": 202, "y": 163},
{"id": "9", "x": 204, "y": 171}]
And i need to regroup point with 20px difference in biggest point with coord of the average of all other points.
It's deal a JSON like that:
[{"id": ["1"], "x": 253, "y": 144},
{"id": ["2"], "x": 142, "y": 355},
{"id": ["3"], "x": 175, "y": 330},
{"id": ["4"], "x": 140, "y": 5},
{"id": ["5"], "x": 307, "y": 306},
{"id": ["6"], "x": 233, "y": 304},
{"id": ["7","8","9"], "x": 206, "y": 165}]
I just need an algorithm to help me to build my own code.
Thank you for all help you can give to me.
Euclidian distance is the shortest path between two points and calculated as
sqrt(pow(x2 - x1, 2) + pow(y2 - y1, 2))
Just iterate through your list of points from the top to the bottom and if the Euclidean distance between any two points is less than 20, remove the second point or group it with the first one, so you won't have to process it again. You can then calculate the average location of that group if you want to.

How can I draw a 3D CAD in browser using webgl with nodes and elements?

I want to visualize it in a browser either using three.js or any other library. Data is available in the following format from ABAQUS.
Node has in the form of [posX, posY, posZ].
Element has data in the form of [Node1, Node2 ...... Node8]
structure_details = {
"nodes": [{
"number": 1,
/* [posX, posY, posZ] */
"position": [0.5, 1.0, 2.0]
},{
"number": 2,
"position": [0.5, 1.0, 2.0]
},{
"number": 3,
"position": [0.5, 1.0, 2.0]
},{
"number": 4,
"position": [0.5, 1.0, 2.0]
}
...],
"elements": [{
"number": 1,
"type": "octahedral",
"nodes": [1, 2, 3, 4, 5, 6, 7, 8],
}
...]
}

Resources