Cannot access locals from +page.server.js

I’m following this tutorial https://www.youtube.com/watch?v=doDKaKDvB30 on how to make a login/registration feature with sveltekit and pocketbase.

Here’s what the hooks.server.js looks like:

import PocketBase from 'pocketbase';

/** @type {import('@sveltejs/kit').Handle} */
export const handle = async ({event, resolve}) => {
    event.locals.pb = new PocketBase('http://localhost:8090');
    event.locals.pb.authStore.loadFromCookie(event.request.headers.get('cookie') || '');
    
    if(event.locals.pb.authStore.isValid) {
        event.locals.user = event.locals.pb.authStore.model;
    }

    const response = await resolve(event);

    response.headers.set('set-cookie', event.locals.pb.authStore.exportToCookie({secure: false}));

    return response;
}

and the +page.server.js for the register screen:

import { redirect } from '@sveltejs/kit';

/** @type {import('./$types').Actions} */
export const actions = {
    register: async ({ locals, request }) => {
        const formData = await request.formData();
                const data = Object.fromEntries([...formData]);
        
                try {
            const newUser = await locals.pb.collection('users').create(data);

                    const {token, user} = await               
locals.pb.collection('users').authWithPassword(data.email, data.password);

        }
        catch(err) {
            console.log("Error: " + err);
            return {
                error: true,
                message: err
            }
        }

                throw redirect(303, "/");
    
        },
};

But when I try to register a new user I get 2 errors:

TypeError: Cannot read properties of undefined (reading 'collection')
Data returned from action inside /register is not serializable: Cannot stringify arbitrary non-POJOs (data..message)

I think that is because the data in locals is not being sent to +page.server.js, but I don’t know why. That’s how it is done in the tutorial and it works!

how to get typescript duplicate property error?

I’m using typescript version 4.9.5 and i want to use an enum as keys of an object. for example:

enum TestEnum {
  value1 = 'value1',
  value2 = 'value2',
}

const variable: {[key in TestEnum]: number} = {
  [TestEnum.value1]: 5,
  [TestEnum.value2]: 7,
  [TestEnum.value1]: 9,
}

Problem is that in this version i wont get typescript duplicate property error. i know that in newer versions (> 5.1) it’s handled. but i can’t use another version.and i know if i use value1 instead of [TestEnum.value1] it will be handled by ts. but i don’t want use enum value directly.
Is there any other way to solve this problem?

Close a redirected browser using Javascript

I have a situation here. I have a form and once the form is submitted I need to run a URL in another browser. But I don’t want the user to see it.
The URL, once it runs on the browser it’s redirecting to another page as part of functionality. Since its redirecting I am unable to close it using JS. I tried window.close() method. But that didn’t work.
Is there any option to implement it.

I tried to implement it using JS but it didn’t work.

Use of nextElementSibling – updating one input box based on value input of another

I am using the following script on a form with multiple results to automatically enter a mark based on the percentage scored in a test. The scripts works fine but only if the input box and the output box are adjacent. I need to lay the score sheet out in a table – or divs but whenever I separate the inputs, the script breaks down. Any help appreciated.

<script>
    function updateInputBox2(inputBox) {
      // Get the value from the current input box
      var inputValue = parseFloat(inputBox.value);

      // Find the corresponding output box
      var outputBox = inputBox.nextElementSibling;

      // Check the range and update the output box accordingly
      var outputBoxValue;
      if (inputValue >= 90) {
        outputBoxValue = 3;
      } else if (inputValue >= 80 && inputValue <= 89) {
        outputBoxValue = 2;
      } else if (inputValue >= 70 && inputValue <= 79) {
        outputBoxValue = 1;
      } else {
        outputBoxValue = 0;
      }

      // Update the value in the corresponding output box
      outputBox.value = outputBoxValue;
    }
  </script>

I would like to adapt the function further so that it can be used with tables or other layout objects. I have tried rewriting the code in various ways but with no success. I am sure I am missing something obvious!

Where to instantiate my classes and still adhere to SRP

My questions is specific to adhering to SRP on the client side where we need to maintain state in our objects instead of adhering to SRP on the server where our state is maintained within a database, which I will post a new question for to shorten this one. This question is full of smaller questions that I dont expect a direct answer to everything , but are mainly asked to explain a thought process.

Out of all of the SOLID principles this is the one I have read up on the most and I simply get confused every time. It’s just not clicking, but not for the want of trying. Ive read the generic ‘it has to have one responsibility’ to ‘it only has one reason to change’ and ‘it is meant to be respond to a single actor’. Then I think it makes sense and I put it into practice and it just gets even more confusing following these quotations.

Here is the summary of what im thinking :

Within a single class as long as the properties all represent the entity we are describing and as long as there are a) not several methods targeting one specific property or b) a group of properties that relate to each other instead of being a standalone property describing the person start to form then we are adhering to SRP.

However when these issues in a or b start to form then we need to refactor to adhere to SRP. Similar to how we create new tables within a mysql database when a column relates to something else other than just the primary key then in a normalised database we would create a new table linking both together through keys. In OOP , at this point we create separate classes for each responsibility?

Let me explain my thought process Example 1 we could store everything within the same class like this, this for me violates SRP

class Person {
  constructor(name,streetName,doorNum){
    this.name = name;
    this.streetName = streetName;
    this.doorNum = doorNum;
  }
  getAddress(){
    return {
    streetName: this.streetName,
    doorNum: this.doorNum  
    }
  }
  changeName(newName){
    this.name = newName;
  }
  changeDoorNumber(num){
    this.doorNum = num;
  }
  getName(){
    return this.name;
  }
}

Although each property plays a part in describing the Person which is the target entity, both the name and the address can be encapsulated within its own class like this.

class Person {
  constructor(name,streetName,doorNum){
    this.name = new Name(name)
    this.address = new Address(streetName,doorNum)
  }
  getAddress(){
    return this.address.getAddress();  
  }
  changeDoorNumber(num){
    this.address.changeDoorNumber(num)
  }
  getName(){
    this.name.getName()
  }
  changeName(newName){
    this.name.changeName(newName)
  }
}

Here we have methods within the Person class that calls methods from the Name and Address classes, but the properties and methods of the Name and Address classes are encapsulated within their own class and supply their own interface to be used within the person class.

This leads me to think where do I instantiate these separate classes effectively to relate them to the entity they refer to. Above I have stored the Address and Name class within the Person class by instantiating the classes within the Person class which I like to refer to as the HOST class. I am also aware I could injection an instantiation of them when creating the object.

However the Person class itself still has the same amount of methods in it, it just doesn’t directly contain the logic of the method and instead just calls methods from the classes within it. Is this ok or shall I be instantiating the person class which instantiates the Name and Address class and then when I want to call a method of the name and address classes then do something like person.name.changeName() ? The Address and Name classes still need to refer to a specific person somehow right so must be instantiated within the Person class ?

Alternatively I could seperate all of these classes entirely and link each association through a common Id, kind of like how a mysql database relational pattern would work. See Below

class Person {
  constructor(id, name ){
    this.id = id;
  }
  getId(){
    return this.id;
  }
}

class Address {
  constructor(person_id, streetName, doorNum){
    this.person_id = person_id;
    this.streetName = streetName;
    this.doorNum = doorNum;
  }
  getAddress (){
    return this;
  }
}

Then do the same with the Name class. Here I could retrieve the address and name through the Id of the person and I wouldn’t then have to bloat my Person class with methods just to keep together classes that belong within the specific person. I haven’t seen this practice client side before which makes me think that this is not a thing?

The next part is the part that confuses me now the most and an answer to this would really help –

So far within these classes I am targeting specific details of each person , name or address. However now I don’t want to carry out a piece of functionality by using the Person details rather than just changing or getting them. Let’s say the Person wants to apply for a bank loan. I want to send a request to the server whom deals with the request and business logic as to whether the person will be successful in his loan application. It’s a relatively small loan and just requires the person name and address to decide upon approval or not. Am I correct in saying that this Loan class doesn’t have to be within the Person class because I can retrieve the name and address from the Person class and pass it to the Loan class? However if I wanted to update a property within the loan class such as doesHaveALoan then now I would need that Loan class to be relatable to a specific person again to so I would move instantiate it or pass it into the players class again because it needs to relate to a specific player? Alternatively I could pass the instantiated Loan object that stores the doesHaveALoan property into a mediator aswell as a second class such as LoanApplication and complete the mediation within there which may mean calling a method to update the Loan class within the specific player . Is this correct or have I misunderstood?

Rather than answering all my questions above I have included them to explain my thought process.

The things I would like an answer to are

  1. Should I couple my separate Name and Address classes within the person class or associate them through a common id ?
    2)Does the Location of the instantiation of my Loan class depend on whether I want to have a property within the class that is coupled to the person making the loan as described above
  2. Shall I create a new class as soon as I have more than one method targeting a property and that property and methods dont work in tandem with other methods or properties within this class as shown above ?

How do I add the fifth point to chart.js?

I have a chart that I created with chart.js and I added four points. I obtained a quadrilateral with these added points. When I want to add a fifth point, I want to get a pentagon instead of this quadrilateral, but the shape is distorted.

//codes with quadrilateral
var ctx = document.getElementById('workingLimitGraph').getContext('2d');
        var minFluidOutletTemp = @Model.SerieLimits.Cooling_MinFluidOutletTemp;
        var maxFluidOutletTemp = @Model.SerieLimits.Cooling_MaxFluidOutletTemp;
        var minAmbientTemp = @Model.SerieLimits.Cooling_MinAmbientTemp;
        var maxAmbientTemp = @Model.SerieLimits.Cooling_MaxAmbientTemp;

        var xAxisMin = minFluidOutletTemp - 5;
        var xAxisMax = maxFluidOutletTemp + 5;
        var yAxisMin = minAmbientTemp - 10;
        var yAxisMax = maxAmbientTemp + 10;

        var myChart = new Chart(ctx, {
            type: 'line',
            data: {
                datasets: [{
                    label: '',
                    data: [
                        { x: minFluidOutletTemp, y: minAmbientTemp },
                        { x: minFluidOutletTemp, y: maxAmbientTemp },
                        { x: maxFluidOutletTemp, y: maxAmbientTemp },
                        { x: maxFluidOutletTemp, y: minAmbientTemp }
                    ],
                    fill: true,
                    backgroundColor: 'rgba(0, 128, 0, 0.3)',
                    borderColor: 'rgba(0, 128, 0, 0.3)',
                    borderWidth: 1,
                    pointRadius: 5,
                    pointBackgroundColor: 'rgba(0, 128, 0, 0.3)',
                    pointBorderColor: 'rgba(0, 128, 0, 0.3)',
                    showLine: true 
                }]
            },
            options: {
                maintainAspectRatio: false,
                scales: {
                    x: {
                        title: {
                            display: true,
                            text: 'Water Outlet Temperature (°C)'
                        },
                        ticks: {
                            stepSize: 1,
                            padding:20,
                        },
                        grid: {
                            display: false
                        },
                        min: xAxisMin,
                        max: xAxisMax,
                        stepSize: 1,
                    },
                    y: {
                        title: {
                            display: true,
                            text: 'Ambient Air Temperature (°C)'
                        },
                        ticks: {
                            stepSize: 10,
                            padding: 20,
                        },
                        min: yAxisMin,
                        max: yAxisMax,
                        stepSize: 10,
                    }
                }
            }
        });

datasets in this code:

{ x: minFluidOutletTemp, y: minAmbientTemp },
{ x: minFluidOutletTemp, y: maxAmbientTemp },
{ x: maxFluidOutletTemp, y: maxAmbientTemp - 10 },
{ x: maxFluidOutletTemp, y: minAmbientTemp },
{ x: minFluidOutletTemp, y: minAmbientTemp },
{ x: minFluidOutletTemp + 2, y: maxAmbientTemp }, 
{ x: maxFluidOutletTemp, y: minAmbientTemp },

I get a pentagon, but I can’t get a perfect pentagon.

quadrilateral
enter image description here
pentagon
enter image description here
it looks like this. I want the pentagon to look like this just like the quadrilateral looks like this. how to do it?

I cannot override a file in Strapi CMS

I try to override file using path “extensionsstrapi-plugin-content-managerservicesContentManager.js” and get every time an error: “error TypeError: Cannot read property ‘routes’ of undefined”.

The contents of the file that needs to be overwritten have not yet been changed

Strapi v3.0.0-beta.17.4

How can I resolve the error?

GLSL Shader Gaussian blur looking rough

I have written my own shader that implements Gaussian blur on the frame. and everything works well, including the edge treatment. But for some reason, the blur looks rough and as if streaks/artifacts are visible. I’ll give you a screenshot of how it looks and how it should look.
Just in case, I will give you additional information that the rendering is on canvas 530×70. the blur in u_radius is 40. the blur I’m trying to achieve is 40.

That’s what I got

glsl render

What am I trying to achieve

filter

I tried to change the radius (u_radius) and samples, and it seems that increasing the samples to 100 and a radius of 0.1 I achieved an approximate effect. but it’s still not what I need and it looks bad. It’s as if the blur is applied only on the x-axis.

here is my GLSL vertex and fragment shader code

 const vertexShader = gl.createShader(gl.VERTEX_SHADER);
       gl.shaderSource(vertexShader, `
           attribute vec2 position;
           void main() {
               gl_Position = vec4(position, 0.0, 1.0);
           }
       `);
       gl.compileShader(vertexShader);
   
       const fragmentShader = gl.createShader(gl.FRAGMENT_SHADER);
       gl.shaderSource(fragmentShader, `
       precision mediump float;
       uniform sampler2D u_image;
       uniform vec2 u_resolution;
       uniform float u_radius;
       
       float gaussian(float x, float sigma) {
           return exp(-0.5 * x * x / (2.0 * sigma * sigma)) / (sqrt(2.0 * 3.14159) * sigma);
       }
       
       vec2 mirror(vec2 st) {
           vec2 mirrored = mod(st, 2.0);
           return mix(mirrored, 2.0 - mirrored, step(1.0, mirrored));
       }
       
       void main() {
           vec2 st = gl_FragCoord.xy / u_resolution;
           vec4 color = vec4(0.0);
           float totalWeight = 0.0;
       
           for (int i = -40; i <= 40; i++) {
               for (int j = -40; j <= 40; j++) {
                   vec2 offset = vec2(float(i), float(j)) / u_resolution;
                   float distance = length(offset);
                   float weight = gaussian(distance, u_radius);
                   color += texture2D(u_image, mirror(st + offset)) * weight;
                   totalWeight += weight;
               }
           }
       
           gl_FragColor = color / totalWeight;
       }
       `);

 gl.compileShader(fragmentShader);

 const program = gl.createProgram();
       gl.attachShader(program, vertexShader);
       gl.attachShader(program, fragmentShader);
       gl.linkProgram(program);
   
       gl.useProgram(program);

   const positionLocation = gl.getAttribLocation(program, 'position');
       const positionBuffer = gl.createBuffer();
       gl.bindBuffer(gl.ARRAY_BUFFER, positionBuffer);
       gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([
           -1.0, -1.0,
           1.0, -1.0,
           -1.0, 1.0,
           -1.0, 1.0,
           1.0, -1.0,
           1.0, 1.0
       ]), gl.STATIC_DRAW);
       gl.enableVertexAttribArray(positionLocation);
       gl.vertexAttribPointer(positionLocation, 2, gl.FLOAT, false, 0, 0);

  const resolutionLocation = gl.getUniformLocation(program, 'u_resolution');
       const radiusLocation = gl.getUniformLocation(program, 'u_radius');
       gl.uniform2f(resolutionLocation, canvas.width, canvas.height);
       gl.uniform1f(radiusLocation, 40);

What causes the Firebase query to fail in this React app?

I am making a chat application with Firebase 9 and React 18.

I run into a problem while working on the search users functionality.

I should be able to search through the registered users. If any are found, they should be displayed in the UsersList component.

The Sidebar component is the parent of both SearchUsers and UsersList components:

export default function Sidebar() {

 const [isSearch, setIsSearch] = useState(false);
 const [searchQuery, setSearchQuery] = useState("");

 return (
    <div className="col-sm-12 col-md-12 col-lg-4 col-xl-3 sidebar active">
      <div className="topbar d-flex align-items-center">
        <YourProfile />
      </div>
      
      
      {/* 2 sibling components */}
      <SearchUsers setIsSearch={setIsSearch} setSearchQuery={setSearchQuery} /> 
      <UsersList isSearch={isSearch} searchQuery={searchQuery} /> 
    </div>
  );
}

In the SearchUsers component I have:

export default function SearchUsers({ setIsSearch, setSearchQuery }) {

  const sendSearchQuery = async (e) => {
    if (e.target.value.length > 2) {
      setSearchQuery(e.target.value);
    } else {
      setSearchQuery("");
    }
  }

  return (
    <div className="search-box">
      <form className="d-flex" action="">
        <button className="search-button text-muted">
          <FontAwesomeIcon icon="fa-search"/>
        </button>
        <input type="text" placeholder="Find people to talk to" className="search-field w-100" onBlur={() => setIsSearch(false)} onFocus={() => setIsSearch(true)} onChange={ sendSearchQuery } />
      </form>
    </div>
  );
}

In the UsersList component I have:

export default function UsersList({isSearch, searchQuery}) {

  const location = useLocation();
  const [users, setUsers] = useState([]);
  const [err, setErr] = useState(false);

  const getUsers = async () => {

    const q = query(collection(db, "users"), (where('firstName', '==', searchQuery),
      or(
        where('lastName', '==', searchQuery),
        where('email', '==', searchQuery)
      )));

    try {
      const querySnapshot = await getDocs(q);
      const usersArray = [];
      querySnapshot.forEach((doc) => {
        if (doc.data() !== null) {
          usersArray.push(doc.data()); 
        }
      });
      setUsers(usersArray); 
    } catch (error) {
      setErr(true);
    }
  }

  const usersList = () => {
    return users.map(user => (
      <UserItem
        key={user.uid}
        user={user}
      />
    ))
  }

  useEffect(() => {
    getUsers();
  }, [location, setUsers])

  return (
    <div className="chat-users">
      {isSearch && !users.length ? <p className="m-0 text-center text-danger">No users found</p> :
        <PerfectScrollbar>
          <ul className="users-list list-unstyled m-0 d-table w-100">
            { usersList() }
          </ul>
        </PerfectScrollbar>
      }

      <p className="text-center">{searchQuery}</p>
    </div>
  );
}

When I enter a query in the search box, it is picked-up by the UsersList component, as expected. The element <p className="text-center">{searchQuery}</p> displays it.

The problem

Evan though I enter a search word I know for sure should return a user (I have hardcoded it for test purposes and it worked), it does not return any users.

Questions:

  1. What causes the described problem?
  2. What is the most reliable way to fix it?

Vaadin – implement dom2image as component

I have spent many hours integrating javascript libraries in Vaadin and I feel like I got stuck.

So I decided to ask this question exemplarily for dom-to-image to export an element from the dom tree to an image.

What I did:

  • Created a class that extends Component
  • Added NpmPackage, (JsModule or JavaScript) and the Tag annotation
  • Created a function appendImg that accepts a component that I can use to get the referencing dom element (here a LMap from https://github.com/xdev-software/vaadin-maps-leaflet-flow) as done by map.clientComponentJsAccessor().

What happens:

  • The NPM package is downloaded
  • No errors are shown neither in the console in my IDE nor in the browser
  • The System out is printed
  • That’s it

When I remove the JS call to the entire domtoimage() function both alerts are shown in the browser. So I am pretty sure that the call causes the malfunction.

My question is now: How to proceed here? I don’t get any errors and I have no clue on where to start fixing the call to domtoimage(). Am I doing sth essentially wrong? Hope you can help me out.

@NpmPackage(value = "dom-to-image", version = "2.6.0")
//@JsModule("dom-to-image")
@JavaScript("dom-to-image/dist/dom-to-image.min.js")
@Tag("dom-to-image")
public class Dom2Image extends Component {

    private static final long serialVersionUID = 1L;
        
    public void appendImg(LMap map) {
        System.out.println("Printing...");
        getElement().executeJs("(function () {"
        + "alert('0');"
        + "domtoimage.toPng($0)"
        + "    .then(function (dataUrl) {"
        + "        console.log('exporting...');"
        + "        var img = new Image();"
        + "        img.src = dataUrl;"
        + "        document.body.appendChild(img);"
        + "    })"
        + "    .catch(function (error) {"
        + "        console.error('oops, something went wrong!', error);"
        + "    })"
        + "alert('1');"
        + "})();", map.clientComponentJsAccessor());
    }
}

JavaScript not working on Ruby on Rails project

I’m trying to follow this (somewhat outdated) Ruby on Rails tutorial and I’m having trouble getting any JavaScript to work. More specifically, I have this js file:

modal.js

$(document).on('turbolinks:load', function() {
    // when a post is clicked, show its full content in a modal window
    $("body").on( "click", ".single-post-card, .single-post-list", function() {
      console.log('test');
      var posted_by = $(this).find('.post-content .posted-by').html();
      var post_heading = $(this).find('.post-content h3').html();
      var post_content = $(this).find('.post-content p').html();
      var interested = $(this).find('.post-content .interested').attr('href');
      $('.modal-header .posted-by').text(posted_by);
      $('.loaded-data h3').text(post_heading);
      $('.loaded-data p').text(post_content);
      $('.loaded-data .interested a').attr('href', interested);
      $('.myModal').modal('show');
    });
  });

that should be applied onto this html.erb file:

_modal.html.erb

<!-- Modal -->
<div  class="modal myModal" 
      tabindex="-1" 
      role="dialog" 
      aria-labelledby="myModalLabel">
  <div class="modal-dialog modal-lg" role="document">
    <div class="modal-content">
      <div class="modal-header">
        <span class="posted-by"></span>
        <button type="button" 
                class="close" 
                data-bs-dismiss="modal" 
                aria-label="Close">
          <span aria-hidden="true">&times;</span>
        </button>
      </div>
        <div class="modal-body">
          <div class="loaded-data">
            <h3></h3>
            <p></p>
            <div class="interested"><a href="">I'm interested</a></div>
          </div><!-- loaded-data -->
        </div><!-- modal-body -->
    </div>
  </div>
</div>

And then there are also these html.erb files:

_post.html.erb

<div class="col-sm-3 single-post-card" id=<%= post_path(post.id) %>>
  <div class="card">
    <div class="card-block">
      <h4 class="post-text">
        <%= truncate(post.title, :length => 60) %>
      </h4>
      <div class="post-content">
        <div class="posted-by">Posted by <%= post.user.name %></div>
        <h3><%= post.title %></h3> 
        <p><%= post.content %></p>
        <%= link_to "I'm interested", post_path(post.id), class: 'interested' %>
      </div>
    </div>
  </div><!-- card -->
</div><!-- col-sm-3 -->

index.html.erb

<%= render 'posts/modal' %>

<div class="container">
  <div class="row">
    <div id="side-menu"  class="col-sm-3">
    </div><!-- side-menu -->

    <div id="main-content" class="col-sm-9">
      <%= render @posts %>
    </div><!-- main-content -->

  </div><!-- row -->
</div><!-- container -->

application.html.erb

<!DOCTYPE html>
<html>
  <head>

    <title>Project01</title>
    <meta name="viewport" content="width=device-width,initial-scale=1">
    <link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-T3c6CoIi6uLrA9TneNEoa7RxnatzjcDSCmG1MXxSR1GAsXEV/Dwwykc2MPK8M2HN" crossorigin="anonymous">
    <script defer src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-C6RzsynM9kWDrMNeT87bh95OGNyZPhcTNXj1NW7RuBCsyN/o0jlpcV8Qyq46cDfL" crossorigin="anonymous"></script>
    

    <%= csrf_meta_tags %>
    <%= csp_meta_tag %>

    <%= stylesheet_link_tag "application", "data-turbo-track": "reload" %>
    <%= javascript_importmap_tags %>

    
  </head>

  <body>
    <%= render 'layouts/navbar' %>
    <div class="mainPage">
      <%= yield %>
    </div>
    
    
  </body>
</html>

The application.js file:

// Configure your import map in config/importmap.rb. Read more: https://github.com/rails/importmap-rails
import "@hotwired/turbo-rails"
import "controllers"


//= require jquery
//= require bootstrap-sprockets
//= require turbolinks

Whole project can be found here.

I’ve tried including the js file in various places through out my app, as well as writing it inside tags in the html file, as well as other answers found on stackoverflow but with no success.

identify similar meshes in threejs

I was trying to identify the meshes which are similar. I did able to check this by comparing triangles and vertices, but i also want to compare dimensions of 2 meshes. how to do this ?
bounding box didn’t work.
is there any way to achieving this using OBB ?