Wavefront obj formatted string as a source for a Viro3DObject instead of using require('/src/theobj.obj') (in react native) - react-native

is it possible to use an .obj notation formatted string as a Viro3DObject* source? So instead of pointing to my /src/models i use a gigantic string which is exactly the same as what an obj file would contain in my local assets?
like so:
objStr = "mtllib objmtl.mtl v -0.7752 0.1285 0.3030 v -0.8354 0.1285 0.3641 v -0.8354 0.1311 0.3641 v -0.7752 0.1311 0.3030 etc..."
let the3DObject = <Viro3DObject>
source={objStr}
</Viro3DObject>
(same goes for the other resources like mtl and images)
And then add the3DObject to the AR or VR scene.
'*' (from the Viro React framework from Viro Media)

Related

Can I have aliases for embedded resources?

I have a set of embedded resources which would be images.
I receive an input string as such "image_1". Using this input string I load 2 images from my resources, image_1_1 and image_1_2.
For this I use ResourceManager.GetObject("image_1_1") etc..
Sometimes 2 or more resources has the same image_x_2, i.e: image_1_2 and image_5_2 is the same image.
How can I have an alias for image_1_2 and image_5_2 to point to the same embedded resource?
Instead of having 2 images of the same thing, which would take up more space.
EDIT:
Since this was not understood, I will provide pseudocode for you so you understand what I am trying to do.
'Imagine this input array of strings is big (50 - 100)
Dim InputString() as String = {"image_1", "image_2", "image_3"}
' image_1_2 and image_3_2 is the same image.
Dim image1 As Bitmap
Dim image2 As Bitmap
For Each str in InputString
image1 = My.Resources.ResourceManager.GetObject(str + "_1")
' If this is image_3_2 it should point towards image_1_2.
image2 = My.Resources.ResourceManager.GetObject(str + "_2")
SomeClass.SomeArray.Add(New SomeImageHolderClass(image1, image2))
Next
Is it possible to edit this in the vbproj file? To have another name to the item?
<ItemGroup>
<None Include="Resources\image_1_2.png" SomeOtherTagAsAlias="image_3_2" />
</ItemGroup>
Thanks.

How to move text in PDF?

Is there a Java or Nodejs library that can move existing text in a PDF file?
I'd like to extract all the text nodes, then move some of them to a new location based on some conditions.
I tried PdfClown, galkahana/HummusJS, Hopding/pdf-lib, but seems they don't have exactly what I need.
can anyone help? thanks
After inspecting the variables, I figured out how to move text, here is the code
PrimitiveComposer composer = new PrimitiveComposer(page);
ContentScanner scanner = composer.getScanner();
tranverse(scanner);
composer.flush();
...
while (level.moveNext()){
ContentObject content = level.getCurrent();
if (content instanceof Text){
...
List<ContentObject> objects = text.getBaseDataObject().getObjects();
for(ContentObject co: objects){
if(co instanceof SetTextMatrix){
List<PdfDirectObject> operands = ((SetTextMatrix)co).getOperands();
PdfInteger y = (PdfInteger)operands.get(5);
operands.set(5, new PdfInteger(y.getIntValue()-100));
}
}

AVAudioUnitEQ / .BandPass filter doesn't work

I can't get the AVAudioUnitEQ to work.
Here's a piece of code that should filter out everything except 659.255Hz +/-0.05 octaves:
// Create Audio Engine
var audioEngine = AVAudioEngine()
// Create Equalizer Node
var equalizerNode = AVAudioUnitEQ(numberOfBands: 1)
var epualizerParameters: AVAudioUnitEQFilterParameters = equalizerNode.bands.first as AVAudioUnitEQFilterParameters
epualizerParameters.filterType = .BandPass
epualizerParameters.frequency = 659.255
epualizerParameters.bandwidth = 0.05
epualizerParameters.bypass = false
audioEngine.attachNode(equalizerNode)
// Configure Audio Engine
var format = audioEngine.inputNode.inputFormatForBus(0)
audioEngine.connect(audioEngine.inputNode, to: equalizerNode, format: format)
audioEngine.connect(equalizerNode, to: audioEngine.outputNode, format: format)
// Start Audio Engine
var error:NSError?
audioEngine.startAndReturnError(&error)
However, when I run it, put on my headphones and sing into the microphone, I can hear myself loud and clear.
Now, according to Wikipedia, the Band Pass filter is:
... a device that passes frequencies within a certain range and
rejects (attenuates) frequencies outside that range.
What am I doing wrong? I want to filter out everything except given frequency range.
It was your EQ params.
I created a github project with sliders and switches. You can hear the difference.
Try it.
This works in my project which uses a playerNode.
var format = engine.mainMixerNode.outputFormatForBus(0)
engine.connect(playerNode, to: EQNode, format: format )
engine.connect(EQNode, to: engine.mainMixerNode, format: format)
I see you're using the engine's inputNode. Try swapping out these few lines (hook into the mixer instead of the outputNode) and let us know if it works.

HMACSHA1 gives different output between JS and VB.Net

I'm trying to translate a JavaScript application of TOTP to VB.Net: http://blog.tinisles.com/2011/10/google-authenticator-one-time-password-algorithm-in-javascript/
I have encountered a problem during translation of the HMAC-part:
//Javascript:
var hmacObj = new jsSHA("Hello World!", 'HEX');
var hmac = hmacObj.getHMAC("secret", 'HEX', 'SHA-1', "HEX");
This is a codesnippet of my translation in VB.Net
'VB.Net:
Dim hmacObjTest As New HMACSHA1(System.Text.Encoding.UTF8.GetBytes("secret"))
Dim hmacTest As Byte() = hmacObjTest.ComputeHash(System.Text.Encoding.UTF8.GetBytes("Hello World!"))
Dim hmacHexTest As New StringBuilder()
For i As Integer = 0 To hmacTest.Length - 1
hmacHexTest.Append(hmacTest(i).ToString("x2"))
Next i
Dim strTest As String = "HMAC = " & hmacHexTest.ToString()
The problem is that i get different output from the two languages:
Output JS: 5efed98b0787c83f9cb0135ba283c390ca49320e //Tested from jsSha demo: http://caligatio.github.io/jsSHA/
Output VB.Net: 87b0154b8420c0b58869ca103f481e824d8876ea
The outputs are not at all the same like they are in this question: hmacsha1 output hex strings different between vb.net and python
Does anyone know where I might be doing something wrong?
Hashes don't work on strings - they work on the binary representation of the string. Now you use UTF-8 as encoding for the dotnet version, while the JavaScript version is very likely not to use UTF-8 - so you get different binary representations, resulting in different hashes.
Use either webttolkit or the hackish var utfstring = unescape(encodeURIComponent(rawstring)); to convert to UTF-8 before calcualting the hash.

Content templates rendering in TYPO3

I've got a strange problem connected with content rendering.
I use following code to grab the content:
lib.otherContent = CONTENT
lib.otherContent {
table = tt_content
select {
pidInList = this
orderBy = sorting
where = colPos=0
languageField = sys_language_uid
}
renderObj = COA
renderObj {
10 = TEXT
10.field = header
10.wrap = <h2>|</h2>
20 = TEXT
20.field = bodytext
20.wrap = <div class="article">|</div>
}
}
and everything works fine, except that I'd like to use also predefined column-content templates other than simple text (Text with image, Images only, Bullet list etc.).
The question is: with what I have to replace renderObj = COA and the rest between the brackets to let the TYPO3 display it properly?
Thanks,
I.
The available cObjects are more or less listed in TSRef, chapter 8.
TypoScript for rendering Text w/image can be found in typo3/sysext/css_styled_content/static/v4.3/setup.txt at line 724, and in the neighborhood you'll find e.g. bullets (below) and image (above), which is referenced in textpic line 731. Variants of this is what you'll write in your renderObj.
You will find more details in the file typo3/sysext/cms/tslib/class.tslib_content.php, where e.g. text w/image is found at or around line 897 and is called IMGTEXT (do a case-sensitive search). See also around line 403 in typo3/sysext/css_styled_content/pi1/class.cssstyledcontent_pi1.php, where the newer css-based rendering takes place.