Importing a GLSL file throws an error - Vite project - import

So Im currently playing around with three.js and have used vite to setup the document.
I've created a separate fragment.glsl so I dont have to write code inside the shadermaterial. But in the console i get the following error:
Uncaught SyntaxError: Unexpected token '{' (at fragment.glsl?import:1:13)
The fragment.glsl file looks like:
void main() {
gl_FragColor = vec4(1., 0., 0., 1.);
};
I tried importing the file from my /shaders/ folder using:
import fragment from './shaders/fragment.glsl'
And expected it to run the code when I used it in my shaders material:
this.material = new THREE.ShaderMaterial({
fragmentShader: fragment,
uniforms: {
progress: {
type: 'f',
value: 0,
},
side: THREE.DoubleSide,
},
})
But all i get is errors in the console. I cant seem to figure out what Im doing wrong. I didnt expect importing a file would be so troublesome. Does anyone see what Im doing wrong?

I faced same problem and solved it by installing vite-plugin-glsl. It has a simple setup instruction, after it was installed the import problem was resolved.

Related

giter8 escape with '\$'

I'm developing giter8 templates for Scala project.
All the templates were running as expected. However, today I faced with error:
Exiting due to error in the template: /var/folders/zg/dspycv2d6sqc92801kmqy3yw0000gn/T/giter8-75157374435862
relative: $name__norm$/src/main/resources/prod-application.conf, toPath: /Users/***/., An unexpected error occurred while processing the template. Check that all literal '$' are properly escaped with '\$'
mentioned file is as follows:
akka {
discovery {
method = akka-dns
kubernetes-api {
pod-namespace = \${SERVICE_NAMESPACE}
pod-label-selector = "app=$name;format="norm"$"
pod-port-name = management
}
I tried different options of $ escaping. I even deleted all the text and tried to build a template but I still receive the same error with pointing to the same file.
Does anyone know possible way to solve this?

Issue with installing Facebook CTF

I am trying to install Facebook CTF from https://github.com/facebook/fbctf
Following the instructions, I execute ./extra/provision.sh -m prod -s $PWD
All goes well, until it gets to the section where it runs grunt. It's hitting this code in a javascript file
const proto = Object.defineProperties(() => {}, {
...styles,
level: {
enumerable: true,
get() {
return this._generator.level;
},
set(level) {
this._generator.level = level;
}
}
});
It's balking at the ellipsis in front of styles.
It's giving this error.
...styles,
^^^
SyntaxError: Unexpected token ...
Has anyone run into this error when install fbctf or can spot a Javascript error? Thanks for your help
I'm using the Quick Setup instructions and ran into a similar issue.
I resolved by it upgrading my nodejs version using npm in the instructions below.
https://phoenixnap.com/kb/update-node-js-version
Note: I did the nodejs installation on command line before running the install command.

Vue import failing

I've created a vue application scaffolded from the vue cli. Almost everything is reacting as expected with my app except for an issue with import.
The following works fine:
import Vuex from 'vuex';
but, this throws errors:
import { VuetronVue, VuetronVuex } from 'vuetron';
vue.use(VuetronVue);
Linting error:
"export 'VuetronVue' was not found in 'vuetron'
and Console error:
Uncaught TypeError: Cannot read property 'install' of undefined
Changing the code to:
import vuetron from 'vuetron'
vue.use(vuetron.VuetronVue);
resolves the issue...
This original code was taken directly from the Vuetron documentation. Does anyone have a suggestion as to why the ES6 notation would cause an issue?
This seems to be because
vuetron/packages/vuetron-plugins/index.js
only exports the default object:
import VuetronVue from './vuetron-vue';
import VuetronVuex from './vuetron-vuex';
export default {
VuetronVue,
VuetronVuex
};
For named imports as stated in the docs you would need a named export.

Using CleanroomLogger in a Swift script fails to resolve DefaultLogConfiguration

I'm just starting to play with Swift 2.0 for scripting and running into an issue with symbols being resolved.
Using Carthage I bootstrap from a Cartfile containing
github "emaloney/CleanroomLogger"
I am able to get CleanroomLogger working inside of Playground by:
Create a Workspace inside of XCode 7.1.1
Add the CleanroomLogger.xcodeproj file from ./Carthage/Checkouts/CleanroomLogger
Create a new Playground in the project
Inside of the playground I enter the code
import CleanroomLogger
var logConfig = DefaultLogConfiguration.init(minimumSeverity: LogSeverity.Debug, synchronousMode: true)
Log.enable(logConfig)
Log.debug?.message("Sample message sent to debug")
Log.debug?.value("Sample value sent to debug")
This plays without error. I only see () as the output in the playground next to each Log.debug? call which is expected. If I open up the Console app I see two entries:
11/20/15 10:33:51.455 PM Cleanroom Logger[70056]: DEBUG | <EXPR>:5 — Sample message sent to debug
11/20/15 10:33:51.455 PM Cleanroom Logger[70056]: DEBUG | <EXPR>:6 — <String: "Sample value sent to debug">
So clearly I have CleanroomLogger checked out and properly built at this point.
I proceed to try and use Cleanroom Logger from a script logger-demo.swift located in the same directory as my Cartfile. This script is identical to the playground code with the addition of the shebang at the start
#!/usr/bin/env swift -F Carthage/Build/Mac
import CleanroomLogger
var logConfig = DefaultLogConfiguration.init(minimumSeverity: LogSeverity.Debug, synchronousMode: true)
Log.enable(logConfig)
Log.debug?.message("Hello from inside my Mac")
Log.debug?.value("This is a test of value")
Running the script results in the following output:
$ ./logger-demo.swift
LLVM ERROR: Program used external function '__TMdV15CleanroomLogger23DefaultLogConfiguration' which could not be resolved!
Why would this resolve in a playground but not from a swift script?
Wow, that sounds complicated ...
Maybe try SwiftyBeaver logger for Swift 2 instead. It is simple(!), supports colors, is fast & is much more feature-complete.
P.S.: I am the creator :)

ActiveXObject is not defined

Getting error "ActiveXObject is not defined" executing this script:
!INC Local Scripts.EAConstants-JScript
function main()
{
var fso = new ActiveXObject("Scripting.FileSystemObject");
}
main();
What am I doing wrong?
You probably don't have the required libraries installed.
I tried your code in my EA (v11.1) and it worked without issues.
A search for the error revealed that it might have something to do with Internet Explorer, see also http://msdn.microsoft.com/en-us/library/ie/7sw4ddf8(v=vs.94).aspx